Class: Cornerstore::Collection

Inherits:
Model::Base show all
Defined in:
lib/cornerstore/api/collection.rb

Defined Under Namespace

Classes: Resource

Instance Attribute Summary collapse

Attributes inherited from Model::Base

#_id, #_slugs, #created_at, #updated_at

Instance Method Summary collapse

Methods inherited from Model::Base

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

Constructor Details

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

Returns a new instance of Collection.



9
10
11
12
13
14
# File 'lib/cornerstore/api/collection.rb', line 9

def initialize(attributes = {}, parent = nil)
  self.products = Cornerstore::Product::Resource.new(self)
  self.childs = Cornerstore::Collection::Resource.new(self, attributes.delete('child_collections') || [], 'childs')
  self.properties = Cornerstore::Property::Resource.new(self, attributes.delete('properties') || [])
  super
end

Dynamic Method Handling

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

Instance Attribute Details

#childsObject

Returns the value of attribute childs.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def childs
  @childs
end

#membersObject

Returns the value of attribute members.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def members
  @members
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def name
  @name
end

#parentObject

Returns the value of attribute parent.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def parent
  @parent
end

#productsObject

Returns the value of attribute products.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def products
  @products
end

#propertiesObject

Returns the value of attribute properties.



2
3
4
# File 'lib/cornerstore/api/collection.rb', line 2

def properties
  @properties
end

Instance Method Details

#attributesObject



16
17
18
19
20
# File 'lib/cornerstore/api/collection.rb', line 16

def attributes
  {
    name: name
  }
end