Class: Ruby::Reflection::ConstantMirror

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

Instance Attribute Summary

Attributes included from AbstractReflection::Mirror

#reflection

Instance Method Summary collapse

Methods inherited from FieldMirror

#initialize, mirror_class, #name

Methods included from AbstractReflection::FieldMirror

#writable?

Methods included from AbstractReflection::Mirror

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

Methods included from AbstractReflection::Mirror::ClassMethods

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

Constructor Details

This class inherits a constructor from Ruby::Reflection::FieldMirror

Instance Method Details

#deleteObject



31
32
33
# File 'lib/ruby/reflection/field_mirror/constant_mirror.rb', line 31

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

#private?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby/reflection/field_mirror/constant_mirror.rb', line 27

def private?
  false
end

#protected?Boolean

Returns:

  • (Boolean)


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

def protected?
  false
end

#public?Boolean

Returns:

  • (Boolean)


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

def public?
  true
end

#valueObject



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

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
  reflection.reflect @object.const_get(@name)
end

#value=(o) ⇒ Object



15
16
17
# File 'lib/ruby/reflection/field_mirror/constant_mirror.rb', line 15

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