Class: Rod::Rest::ResourceMetadata
- Inherits:
-
Object
- Object
- Rod::Rest::ResourceMetadata
- Defined in:
- lib/rod/rest/resource_metadata.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#indexed_properties ⇒ Object
readonly
Returns the value of attribute indexed_properties.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#plural_associations ⇒ Object
readonly
Returns the value of attribute plural_associations.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#singular_associations ⇒ Object
readonly
Returns the value of attribute singular_associations.
Instance Method Summary collapse
-
#initialize(name, description, options = {}) ⇒ ResourceMetadata
constructor
Create new resource metadata for a resource with
name
anddescription
. -
#inspect ⇒ Object
Description of the metadata.
-
#to_s ⇒ Object
Description of the metadata.
Constructor Details
#initialize(name, description, options = {}) ⇒ ResourceMetadata
Create new resource metadata for a resource with name
and description
. Options:
-
property_factory
- factory used to create descriptions of the properties
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rod/rest/resource_metadata.rb', line 10 def initialize(name,description,={}) @description = description @name = name.to_s @property_factory = [:property_factory] || PropertyMetadata @fields = create_properties(description[:fields]) @singular_associations = create_properties(description[:has_one]) @plural_associations = create_properties(description[:has_many]) @properties = @fields + @singular_associations + @plural_associations @indexed_properties = @properties.select{|p| p.indexed? } end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def fields @fields end |
#indexed_properties ⇒ Object (readonly)
Returns the value of attribute indexed_properties.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def indexed_properties @indexed_properties end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def name @name end |
#plural_associations ⇒ Object (readonly)
Returns the value of attribute plural_associations.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def plural_associations @plural_associations end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def properties @properties end |
#singular_associations ⇒ Object (readonly)
Returns the value of attribute singular_associations.
4 5 6 |
# File 'lib/rod/rest/resource_metadata.rb', line 4 def singular_associations @singular_associations end |
Instance Method Details
#inspect ⇒ Object
Description of the metadata.
22 23 24 |
# File 'lib/rod/rest/resource_metadata.rb', line 22 def inspect @description.inspect end |
#to_s ⇒ Object
Description of the metadata.
27 28 29 |
# File 'lib/rod/rest/resource_metadata.rb', line 27 def to_s @description.to_s end |