Class: Rod::Rest::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/rod/rest/metadata.rb

Constant Summary collapse

ROD_KEY =
/\ARod\b/

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  @description = options.fetch(:description)
  parser = options[:parser] || JSON
  @resource_metadata_factory = options[:resource_metadata_factory] || ResourceMetadata
  @resources = create_resource_descriptions(parser.parse(@description, symbolize_names: true))
end

Instance Attribute Details

#descriptionObject (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

#inspectObject

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

#resourcesObject

Return collection of resource metadata.



21
22
23
# File 'lib/rod/rest/metadata.rb', line 21

def resources
  @resources
end

#to_sObject

Returns the description of the metadata.



31
32
33
# File 'lib/rod/rest/metadata.rb', line 31

def to_s
  @description.to_s
end