Class: Rod::Rest::ResourceMetadata

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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,options={})
  @description = description
  @name = name.to_s
  @property_factory = options[: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

#fieldsObject (readonly)

Returns the value of attribute fields.



4
5
6
# File 'lib/rod/rest/resource_metadata.rb', line 4

def fields
  @fields
end

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

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/rod/rest/resource_metadata.rb', line 4

def name
  @name
end

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

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/rod/rest/resource_metadata.rb', line 4

def properties
  @properties
end

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

#inspectObject

Description of the metadata.



22
23
24
# File 'lib/rod/rest/resource_metadata.rb', line 22

def inspect
  @description.inspect
end

#to_sObject

Description of the metadata.



27
28
29
# File 'lib/rod/rest/resource_metadata.rb', line 27

def to_s
  @description.to_s
end