Class: Collection

Inherits:
Base
  • Object
show all
Defined in:
app/models/collection.rb

Constant Summary

Constants inherited from Base

Base::BASE_URL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rootsObject



2
3
4
# File 'app/models/collection.rb', line 2

def self.roots
  self.find(:all, :from => "/v1/collections/roots.xml")
end

Instance Method Details

#ancestorsObject



14
15
16
# File 'app/models/collection.rb', line 14

def ancestors
  Collection.find(:all, :from => "/v1/collections/#{self.handle}/ancestors.xml")
end

#childrenObject



18
19
20
# File 'app/models/collection.rb', line 18

def children
  Collection.find(:all, :from => "/v1/collections/#{self.handle}/children.xml")
end

#imageObject



30
31
32
33
34
35
# File 'app/models/collection.rb', line 30

def image
  dragonfly = Dragonfly[:images]
  dragonfly.url_host = 'http://cdn.storesapp.com'
  dragonfly.url_path_prefix = '/images'
  dragonfly.fetch(self.image_uid)
end

#parentObject



10
11
12
# File 'app/models/collection.rb', line 10

def parent
  Collection.find(:one, :from => "/v1/collections/#{self.parent_id}.xml")
end

#productsObject



26
27
28
# File 'app/models/collection.rb', line 26

def products
  Product.find(:all, :from => "/v1/collections/#{self.handle}/products.xml")
end

#root?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/models/collection.rb', line 6

def root?
  self.parent_id.blank?
end

#siblingsObject



22
23
24
# File 'app/models/collection.rb', line 22

def siblings
  Collection.find(:all, :from => "/v1/collections/#{self.handle}/siblings.xml")
end