Sha256: dfd4df9cefd0eefa40d0a8431d50b189234f95fac4dc5a63b057203b2f3dd62e

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

module Mirrors
  class ConstantMirror < FieldMirror
    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

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

    def public?
      true
    end

    def protected?
      false
    end

    def private?
      false
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mirrors-0.0.3 lib/mirrors/field_mirror/constant_mirror.rb
mirrors-0.0.2 lib/mirrors/field_mirror/constant_mirror.rb
mirrors-0.0.1 lib/mirrors/field_mirror/constant_mirror.rb