meta

Crystal meta methods

meta

This shard is based on a duscussion I had with @asterite (the retired creator of the Crystal programming language) in this forum thread.

Honestly, all the credit for this goes to him.

NOTICE: Not all helper methods will work in every situation, because I don't fully understand the code myself, I just copied it and made a few tweaks, so, it might not work perfectly.

Usage

method 1

  1. Add the dependency to your shard.yml:
   dependencies:
     meta:
       github: crystal-china/meta
  1. require it directly.
require "meta"

There are many methods defined on Class/Object, check spec for usage.

method 2 (preferred)

There is another more convenient way to use meta.cr, you even don't need add meta into shard.yml as dependency!

  1. Copy file meta.cr to a local folder, e.g. /home/foo/crystal/meta/meta.cr

  2. Add following code to the file where you want those meta helper methods.

{{ read_file("/home/foo/crystal/meta/meta.cr").id }}

This use read_file macro to paste the content of meta.cr into the file where you want to use it.

method 3

You can add the folder where meta.cr is located to CRYSTAL_PATH and require it.

Contributing

  1. Fork it (https://github.com/crystal-china/meta/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

meta

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • 18 days ago
  • June 3, 2025
License

MIT License

Links
Synced at

Sun, 22 Jun 2025 18:28:11 GMT

Languages