Class: Dawanda::Shop

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

Overview

Shop

Represents a single Dawanda shop. Users may or may not have an associated shop - check the result of User#seller? to find out.

A shop has the following attributes:

name

The shop’s name

created_at

An announcement to buyers (displays on the shop’s home page)

updated_at

The message sent to users who buy from this shop

banner_image_url

The full URL to the shops’s banner image

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included

Class Method Details

.all(params = {}) ⇒ Object



47
48
49
# File 'lib/dawanda/shop.rb', line 47

def self.all(params = {})
  find_all_by_method('shops')
end

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

Search for shops with given keyword



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

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

Instance Method Details

#created_atObject

Time that this shop was created



31
32
33
# File 'lib/dawanda/shop.rb', line 31

def created_at
  Time.parse(created)
end

#products(params = {}) ⇒ Object

A collection of products in this user’s shop. See Dawanda::Product for more information



59
60
61
# File 'lib/dawanda/shop.rb', line 59

def products(params = {})
  @products ||= Product.find_all_by_shop_id(user_id.to_s, params)
end

#shop_categories(params = {}) ⇒ Object

All shop categories in this shop. See Dawanda::ShopCategory for more information



69
70
71
# File 'lib/dawanda/shop.rb', line 69

def shop_categories(params = {})
  @shop_categories ||= ShopCategory.find_all_by_shop_id(user_id.to_s, params)
end

#shop_window_productsObject

shop_window_products



52
53
54
# File 'lib/dawanda/shop.rb', line 52

def shop_window_products
  @shop_window_products ||= Product.find_window_products_by_user_id(:user_id => user_id)
end

#updated_atObject

Time that this shop was last updated



37
38
39
# File 'lib/dawanda/shop.rb', line 37

def updated_at
  Time.parse(updated)
end

#user(params = {}) ⇒ Object

The user who runs this shop. See Dawanda::User for more information



64
65
66
# File 'lib/dawanda/shop.rb', line 64

def user(params = {})
  @user ||= User.find_by_user_id(user_id, params)
end