Class: ObjectReflection
- Defined in:
- lib/gems/facets-2.4.5/lib/more/facets/reflection.rb
Overview
ObjectReflection
obj.__object__.id
obj.__object__.class
NOTE: This is still an expirmental library.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(object) ⇒ ObjectReflection
constructor
A new instance of ObjectReflection.
-
#method_missing(s, *a, &b) ⇒ Object
Kernel.instance_methods.select{ |m| m =~ /^instance_/ }.each do |m| meth = m.to_s.sub(/^instance_/, ”) module_eval %{ def #meth(*a, &b) _bind_method(:#m).call(*a,&b) end } end.
Constructor Details
#initialize(object) ⇒ ObjectReflection
Returns a new instance of ObjectReflection.
52 53 54 55 |
# File 'lib/gems/facets-2.4.5/lib/more/facets/reflection.rb', line 52 def initialize(object) @self = object @meth = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s, *a, &b) ⇒ Object
Kernel.instance_methods.select{ |m| m =~ /^instance_/ }.each do |m|
meth = m.to_s.sub(/^instance_/, '')
module_eval %{
def #{meth}(*a, &b)
_bind_method(:#{m}).call(*a,&b)
end
}
end
71 72 73 |
# File 'lib/gems/facets-2.4.5/lib/more/facets/reflection.rb', line 71 def method_missing(s, *a, &b) _bind_method(s).call(*a, &b) end |
Instance Method Details
#id ⇒ Object
58 59 60 |
# File 'lib/gems/facets-2.4.5/lib/more/facets/reflection.rb', line 58 def id _bind_method(:object_id).call end |