Class: Dawanda::User

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

Overview

User

Represents a single Dawanda user - has the following attributes:

id

The unique identifier for this user

name

This user’s username

city

The user’s city / state (optional)

sex

The user’s gender

transaction_sold_count

How many products have been sold by this user

is_seller

Is this user a seller?

bio

User’s biography

restful_path
url

The full URL to this user’s profile page / shop (if seller)

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



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

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

Instance Method Details

#image_170xObject



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

def image_170x
  images.first['image_170x']
end

#image_40x40Object



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

def image_40x40
  images.first['image_40x40']
end

#image_80x80Object



51
52
53
# File 'lib/dawanda/user.rb', line 51

def image_80x80
  images.first['image_80x80']
end

#pinboards(params = {}) ⇒ Object



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

def pinboards(params = {})
  Pinboard.find_all_by_user_id(id, params)
end

#seller?Boolean

Is this user a seller?

Returns:

  • (Boolean)


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

def seller?
  is_seller
end

#shop(params = {}) ⇒ Object

This user’s shop, returns nil if user is not a seller. See Dawanda::Shop for more information.



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

def shop(params = {})
  @shop ||= Shop.find_by_user_id(id, params) if seller?
end