Class: ObjectReflection

Inherits:
Object show all
Defined in:
lib/more/facets/reflection.rb

Direct Known Subclasses

InstanceReflection

Constant Summary collapse

REFLECTION_METHODS =
[
  :object_id, :class, :methods, :send
] + Kernel.instance_methods.select{ |m| m =~ /^object_/ }

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectReflection

Returns a new instance of ObjectReflection.



41
42
43
44
45
46
47
# File 'lib/more/facets/reflection.rb', line 41

def initialize(object)
  @self = object
  @meta = REFLECTION_METHODS.inject({}) do |rproc, meth|
    rproc[meth.to_sym] = Kernel.instance_method(meth).bind(@self)
    rproc
  end
end

Instance Method Details

#idObject



51
52
53
# File 'lib/more/facets/reflection.rb', line 51

def id
  @meta[:object_id].call
end