Class: Maglev::Reflection::FieldMirror

Inherits:
Mirror show all
Includes:
AbstractReflection::FieldMirror
Defined in:
lib/maglev/reflection/field_mirror.rb

Direct Known Subclasses

FixedInstanceVariableMirror

Defined Under Namespace

Classes: Field

Instance Attribute Summary

Attributes included from AbstractReflection::Mirror

#reflection

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AbstractReflection::FieldMirror

#delete, #private?, #protected?, #public?, #value, #value=, #writable?

Methods included from AbstractReflection::Mirror

#mirrors?, #reflectee

Methods included from AbstractReflection::Mirror::ClassMethods

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

Constructor Details

#initialize(obj) ⇒ FieldMirror

Returns a new instance of FieldMirror.



28
29
30
31
32
# File 'lib/maglev/reflection/field_mirror.rb', line 28

def initialize(obj)
  super
  @object = obj.object
  @name = obj.name
end

Class Method Details

.mirror_class(field) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/maglev/reflection/field_mirror.rb', line 13

def self.mirror_class(field)
  if reflects?(field)
    case
    when field.name.start_with?("@@")
      Ruby::Reflection::ClassVariableMirror
    when field.name.start_with?("@")
      Ruby::Reflection::InstanceVariableMirror
    when field.name === Symbol
      FixedInstanceVariableMirror
    else
      Ruby::Reflection::ConstantMirror
    end
  end
end

Instance Method Details

#nameObject



34
35
36
# File 'lib/maglev/reflection/field_mirror.rb', line 34

def name
  @name
end