Class: Rod::Rest::Metadata
- Inherits:
-
Object
- Object
- Rod::Rest::Metadata
- Defined in:
- lib/rod/rest/metadata.rb
Constant Summary collapse
- ROD_KEY =
/\ARod\b/
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Metadata
constructor
Initializes the metadata via the options: * description - text representation of the metadata * parser - parser used to parse the text representation of the metadata * resource_metadata_factory - factory used to create metadata for the resources.
-
#inspect ⇒ Object
Returns the description of the metadata and the class name.
-
#resources ⇒ Object
Return collection of resource metadata.
-
#to_s ⇒ Object
Returns the description of the metadata.
Constructor Details
#initialize(options = {}) ⇒ Metadata
Initializes the metadata via the options:
-
description - text representation of the metadata
-
parser - parser used to parse the text representation of the metadata
-
resource_metadata_factory - factory used to create metadata for the resources
13 14 15 16 17 18 |
# File 'lib/rod/rest/metadata.rb', line 13 def initialize(={}) @description = .fetch(:description) parser = [:parser] || JSON @resource_metadata_factory = [:resource_metadata_factory] || ResourceMetadata @resources = create_resource_descriptions(parser.parse(@description, symbolize_names: true)) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/rod/rest/metadata.rb', line 6 def description @description end |
Instance Method Details
#inspect ⇒ Object
Returns the description of the metadata and the class name.
26 27 28 |
# File 'lib/rod/rest/metadata.rb', line 26 def inspect "#{self.class}<#{@description.inspect}>" end |
#resources ⇒ Object
Return collection of resource metadata.
21 22 23 |
# File 'lib/rod/rest/metadata.rb', line 21 def resources @resources end |
#to_s ⇒ Object
Returns the description of the metadata.
31 32 33 |
# File 'lib/rod/rest/metadata.rb', line 31 def to_s @description.to_s end |