Class: Inspector::PropertyMetadata

Inherits:
Object
  • Object
show all
Includes:
Metadata
Defined in:
lib/inspector/property_metadata.rb

Instance Attribute Summary collapse

Attributes included from Metadata

#children_metadata, #constraints, #type

Instance Method Summary collapse

Methods included from Metadata

#attribute, #attribute_metadatas, #children, #each_item, #property, #property_metadatas, #should, #should_not

Methods included from Constraints

#be_email, #be_empty, #be_false, #be_true, #eq, #have, #have_at_least, #have_at_most, #method_missing, #validate

Methods included from Constraint

#negate!, #positive?, #validator

Constructor Details

#initialize(type, property_name) ⇒ PropertyMetadata

Returns a new instance of PropertyMetadata.



7
8
9
10
# File 'lib/inspector/property_metadata.rb', line 7

def initialize(type, property_name)
  @property_name = property_name
  super(type)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Inspector::Constraints

Instance Attribute Details

#property_nameObject (readonly)

Returns the value of attribute property_name.



5
6
7
# File 'lib/inspector/property_metadata.rb', line 5

def property_name
  @property_name
end

Instance Method Details

#property_value(object) ⇒ Object



12
13
14
15
16
17
# File 'lib/inspector/property_metadata.rb', line 12

def property_value(object)
  object.__send__(:[], @property_name)
rescue NoMethodError
  raise "metadata for #{@type.inspect} contains property metadata, however " +
        "#{object.inspect}[#{@property_name.inspect}] is not defined"
end