Class: Mirrors::ConstantMirror

Inherits:
FieldMirror show all
Defined in:
lib/mirrors/field_mirror/constant_mirror.rb

Instance Attribute Summary

Attributes inherited from FieldMirror

#name

Instance Method Summary collapse

Methods inherited from FieldMirror

#defining_class, #initialize

Methods inherited from Mirror

#initialize, #mirrors?, #name, #reflectee, #subject_id

Constructor Details

This class inherits a constructor from Mirrors::FieldMirror

Instance Method Details

#deleteObject



30
31
32
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 30

def delete
  @object.send(:remove_const, @name)
end

#private?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 26

def private?
  false
end

#protected?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 22

def protected?
  false
end

#public?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 18

def public?
  true
end

#valueObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 3

def value
  if path = @object.autoload?(@name)
    unless $LOADED_FEATURES.include?(path) ||
        $LOADED_FEATURES.include?(File.expand_path(path))
      # Do not trigger autoload
      return nil
    end
  end
  Mirrors.reflect @object.const_get(@name)
end

#value=(o) ⇒ Object



14
15
16
# File 'lib/mirrors/field_mirror/constant_mirror.rb', line 14

def value=(o)
  @object.const_set(@name, o)
end