Sha256: 21a1c310fc5aa4f6a880528cfe02175c5e86b3e1c2fb9d6eff8a061a3088a343

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

module Ruby
  class Reflection
    class FieldMirror < Mirror
      include AbstractReflection::FieldMirror
      Field = Struct.new(:object, :name)
      reflect! Field

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

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

      def name
        @name
      end
    end
  end
end

require 'ruby/reflection/field_mirror/class_variable_mirror'
require 'ruby/reflection/field_mirror/instance_variable_mirror'
require 'ruby/reflection/field_mirror/constant_mirror'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubymirrors-0.0.3 lib/ruby/reflection/field_mirror.rb
rubymirrors-0.0.2 lib/ruby/reflection/field_mirror.rb
rubymirrors-0.0.1 lib/ruby/reflection/field_mirror.rb