Class: Cornerstore::Property

Inherits:
Model::Base show all
Includes:
Model::Writable
Defined in:
lib/cornerstore/api/property.rb

Defined Under Namespace

Classes: Resource

Instance Attribute Summary collapse

Attributes inherited from Model::Base

#_id, #_slugs, #created_at, #parent, #updated_at

Instance Method Summary collapse

Methods included from Model::Writable

create, #destroy, #new?, #save, #to_key

Methods inherited from Model::Base

#==, #attributes=, #inspect, method_missing, #method_missing, #to_param

Constructor Details

#initialize(attributes = {}, parent = nil) ⇒ Property

Returns a new instance of Property.



19
20
21
22
23
24
# File 'lib/cornerstore/api/property.rb', line 19

def initialize(attributes = {}, parent = nil)
  @key = attributes.delete(:key)
  @value = attributes.delete(:value)
      
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cornerstore::Model::Base

Instance Attribute Details

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/cornerstore/api/property.rb', line 4

def key
  @key
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/cornerstore/api/property.rb', line 4

def value
  @value
end

Instance Method Details

#attributesObject



7
8
9
10
11
12
# File 'lib/cornerstore/api/property.rb', line 7

def attributes
  {
    key: key,
    value: value
  }
end

#urlObject

TODO: Rewrite #url on base model to automatically detect parent/url depth.



15
16
17
# File 'lib/cornerstore/api/property.rb', line 15

def url
  super(2)
end