Class: Ruby::Reflection::FieldMirror

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

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.



17
18
19
20
21
# File 'lib/ruby/reflection/field_mirror.rb', line 17

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

Class Method Details

.mirror_class(field) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ruby/reflection/field_mirror.rb', line 8

def self.mirror_class(field)
  return unless reflects? field
  case field.name.to_s
  when /^@@/ then ClassVariableMirror
  when /^@/  then InstanceVariableMirror
  else            ConstantMirror
  end
end

Instance Method Details

#nameObject



23
24
25
# File 'lib/ruby/reflection/field_mirror.rb', line 23

def name
  @name
end