meta
Version, currently 0.2.01 version
- 0.2.0latestMay 8, 2026
github.com/crystal-china/meta
Print methods of Class/Object etc for Crystal
Installation
# Add this to your shard.yml
dependencies:
meta:
github: crystal-china/meta
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
>= 1.16.3- License
- MIT
- Authors
- Ary Borenszweig, Billy.Zheng
Dependencies
Runtime Dependencies
- awesome_print*github: crystal-china/awesome_print
README
meta
Compile-time introspection helpers for Crystal.
meta exposes information from Crystal's macro system as ordinary Crystal values. It can list
methods, class methods, subclasses, ancestors, constants, instance variables, and superclass
chains.
This shard is based on an idea shared by Ary Borenszweig in this Crystal forum thread: https://forum.crystal-lang.org/t/print-out-the-instance-methods-defined-class-or-the-path-where-the-current-class-is/4771/2
Installation
dependencies:
meta:
github: crystal-china/meta
Then:
require "meta"
Usage
class Foo
def hello(name : String) : Nil
end
end
Foo.methods
# => [def hello(name : String) : Nil]
Foo.new.methods
Foo.new.instance_vars
Foo.new.superclass
Foo.new.superclasses
Foo.new.all_methods
Foo.subclasses
Foo.all_subclasses
Foo.class_methods
Foo.constants
Foo.ancestors
Foo.includers
all_methods returns methods grouped by the class or module they come from:
Foo.new.all_methods
# => Hash(String, Array(Crystal::Meta::AbstractMethod))
Use awesome_print for readable output:
require "awesome_print"
require "./src/meta"
class Foo
def foo; end
end
module Baz
def baz; end
end
class Bar < Foo
include Baz
def bar; end
end
ap! Bar.new.all_methods

Direct File Usage
You can also paste src/meta.cr into a file at compile time:
{{ read_file("/path/to/meta.cr").id }}
This is useful when you want the helpers locally without adding a shard dependency.
Notes
These helpers rely on Crystal macro metadata, so they are mostly useful at compile time and may not behave like runtime reflection in dynamic languages.
See spec/meta_spec.cr for more examples.
Contributors
- Ary Borenszweig
- Billy.Zheng vil963@gmail.com
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- May 8, 2026
- Commit
2dcd7fcfa8da- Crystal
>= 1.16.3- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/crystal-china/meta
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 1