Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
/ mirrors Public archive

Mirrors provides a parallel-world reflection API for ruby

License

Notifications You must be signed in to change notification settings

Shopify/mirrors

Repository files navigation

Mirrors Code Climate Build Status Yard Docs

Docs forthcoming, but here's a usage example:

gem install mirrors
cm = Mirrors.reflect(String)
puts cm.inspect
# => #<Mirrors::ClassMirror...>

mms = cm.instance_methods
mm = mms.last

puts mm.inspect
# => #<Mirrors::MethodMirror...>

puts mm.name
# => initialize_copy

puts mm.defining_class.name
# => String

puts cm.instance_methods.group_by(&:visibility).map { |vis, ms| [vis, ms.count] }
# => [[:public, 118], [:private, 2]]

require 'base64'
enc = Mirrors.reflect(Base64).method(:strict_encode64)

puts enc.source
# => "def strict_encode64(bin)\n  [bin].pack(\"m0\")\nend"

puts enc.comment
# => "# Returns the Base64-encoded version of +bin+.\n# This method complies with RFC 4648.\n# No line feeds are added.\n"

puts enc.references.map(&:message)
# => [:pack]

About

Mirrors provides a parallel-world reflection API for ruby

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •