Class: Mirrors::FieldMirror

Inherits:
Mirror
  • Object
show all
Defined in:
lib/mirrors/field_mirror.rb

Overview

A class to reflect on instance, class, and class instance variables, as well as constants.

Defined Under Namespace

Classes: Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Mirror

#mirrors?, #reflectee, #subject_id

Constructor Details

#initialize(obj) ⇒ FieldMirror

Returns a new instance of FieldMirror.



9
10
11
12
13
# File 'lib/mirrors/field_mirror.rb', line 9

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/mirrors/field_mirror.rb', line 7

def name
  @name
end

Instance Method Details

#defining_classClassMirror

Returns The class this method was originally defined in.

Returns:

  • (ClassMirror)

    The class this method was originally defined in



16
17
18
# File 'lib/mirrors/field_mirror.rb', line 16

def defining_class
  Mirrors.reflect(@object)
end