Module: AbstractReflection::Mirror

Extended by:
ClassMethods
Included in:
CompilerMirror, FieldMirror, GCMirror, MethodMirror, ObjectMirror, StackFrameMirror, ThreadMirror, Ruby::Reflection::Mirror
Defined in:
lib/abstract_reflection/mirror.rb

Overview

The basic mirror. This is the lib code. It is also the factory to use for creating new mirrors on any kind of object. Its #reflect class method will return an appropriate mirror for a given object, provided one has been registered. The [ObjectMirror] class should have been registered as the fallback case for any kind of object, but that may depend on the specific API implementation.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

included, mirror_class, new, reflect, reflect!, reflects?, register_mirror

Instance Attribute Details

#reflectionObject

Returns the value of attribute reflection.



87
88
89
# File 'lib/abstract_reflection/mirror.rb', line 87

def reflection
  @reflection
end

Instance Method Details

#initialize(obj) ⇒ Object



89
90
91
# File 'lib/abstract_reflection/mirror.rb', line 89

def initialize(obj)
  @subject = obj
end

#mirrors?(other) ⇒ Boolean

The equivalent to #==/#eql? for comparison of mirrors against objects

Returns:

  • (Boolean)


99
100
101
# File 'lib/abstract_reflection/mirror.rb', line 99

def mirrors?(other)
  @subject == other
end

#nameObject

A generic representation of the object under observation.



94
95
96
# File 'lib/abstract_reflection/mirror.rb', line 94

def name
  @subject.inspect
end

#reflecteeObject

Accessor to the reflected object



104
105
106
# File 'lib/abstract_reflection/mirror.rb', line 104

def reflectee
  @subject
end