Class: Inspector::AttributeMetadata
- Inherits:
-
Object
- Object
- Inspector::AttributeMetadata
- Includes:
- Metadata
- Defined in:
- lib/inspector/attribute_metadata.rb
Instance Attribute Summary collapse
-
#attribute_name ⇒ Object
readonly
Returns the value of attribute attribute_name.
Attributes included from Metadata
#children_metadata, #constraints, #type
Instance Method Summary collapse
- #attribute_value(object) ⇒ Object
-
#initialize(type, attribute_name) ⇒ AttributeMetadata
constructor
A new instance of AttributeMetadata.
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, attribute_name) ⇒ AttributeMetadata
Returns a new instance of AttributeMetadata.
7 8 9 10 |
# File 'lib/inspector/attribute_metadata.rb', line 7 def initialize(type, attribute_name) @attribute_name = attribute_name.to_sym super(type) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Inspector::Constraints
Instance Attribute Details
#attribute_name ⇒ Object (readonly)
Returns the value of attribute attribute_name.
5 6 7 |
# File 'lib/inspector/attribute_metadata.rb', line 5 def attribute_name @attribute_name end |
Instance Method Details
#attribute_value(object) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/inspector/attribute_metadata.rb', line 12 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 |