Sha256: 342ea3eedc5017ab6ecdd187c2253ee6e16fa12960a19ee50945793be70bcc11

Contents?: true

Size: 483 Bytes

Versions: 1

Compression:

Stored size: 483 Bytes

Contents

module Inspector
  class AttributeMetadata
    include Metadata

    attr_reader :attribute_name

    def initialize(type, attribute_name)
      @attribute_name = attribute_name.to_sym
      super(type)
    end

    def attribute_value(object)
      object.__send__(@attribute_name)
    rescue NoMethodError
      raise "metadata for #{@type.inspect} contains attribute metadata, however " +
            "#{object.inspect}.#{@attribute_name.inspect} is not defined"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
object-inspector-0.1.0 lib/inspector/attribute_metadata.rb