Sha256: 41cca08761eab46d3a6214287c7bfdb64a2046ecf90322ab3607a38dd87c564d

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

module Mirrors
  # A class to reflect on instance, class, and class instance variables,
  # as well as constants.
  class FieldMirror < Mirror
    Field = Struct.new(:object, :name)

    attr_reader :name

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

    # @return [ClassMirror] The class this method was originally defined in
    def defining_class
      Mirrors.reflect(@object)
    end
  end
end

require 'mirrors/field_mirror/class_variable_mirror'
require 'mirrors/field_mirror/instance_variable_mirror'
require 'mirrors/field_mirror/constant_mirror'

Version data entries

3 entries across 3 versions & 1 rubygems

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