Class: Dawanda::Product

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/dawanda/product.rb

Overview

id

The unique identifier for this product

name

The title of this product

description

This product’s full description

view_count

The number of times this product has been viewed

product_url

The full URL to this product’s detail page

price

The price of this product item

quantity

The number of items available for sale

tags

An array of tags that the seller has used for this product

materials

Any array of materials that was used in the production of this item

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included

Class Method Details

.search(keyword, params = {}) ⇒ Object

Search for users with given keyword



54
55
56
57
# File 'lib/dawanda/product.rb', line 54

def self.search(keyword, params = {})
  params.update(:keyword => keyword)
  self.find_all_by_method('search', params)
end

.search_by_color(color, keyword, params = {}) ⇒ Object

Search for users with given keyword and color



60
61
62
63
# File 'lib/dawanda/product.rb', line 60

def self.search_by_color(color, keyword, params = {})
  params.update(:keyword => keyword)
  self.find_all_by_hex_search(color, params)
end

Instance Method Details

#category(params = {}) ⇒ Object



72
73
74
# File 'lib/dawanda/product.rb', line 72

def category(params = {})
  Category.find_by_id(category_id)
end

#created_atObject

Time that this product was created



43
44
45
# File 'lib/dawanda/product.rb', line 43

def created_at
  Time.parse(created)
end

#ending_atObject

Time that this product is ending (will be removed from store)



49
50
51
# File 'lib/dawanda/product.rb', line 49

def ending_at
  Time.parse(ending)
end

#image_25x25Object

The primary image for this product. See Dawanda::Image for more information



68
69
70
# File 'lib/dawanda/product.rb', line 68

def image_25x25
  images.first['image_25x25']
end

#shop(params = {}) ⇒ Object



76
77
78
# File 'lib/dawanda/product.rb', line 76

def shop(params = {})
  Shop.find_by_user_id(user["id"])
end