Class: Top4R::User
- Inherits:
-
Object
- Object
- Top4R::User
- Includes:
- ModelMixin
- Defined in:
- lib/top4r/model/user.rb
Overview
User Model
Constant Summary collapse
- @@ATTRIBUTES =
[:id, :user_id, :nick, :sex, :buyer_credit, :seller_credit, :location, :created, :last_visit, :birthday, :type, :has_more_pic, :item_img_num, :item_img_size, :prop_img_num, :prop_img_size, :auto_repost, :promoted_type, :status, :alipay_bind, :consumer_protection, :other_attrs]
Class Method Summary collapse
- .attributes ⇒ Object
- .default_private_fields ⇒ Object
- .default_public_fields ⇒ Object
- .find(u, client) ⇒ Object
Instance Method Summary collapse
Methods included from ModelMixin
Class Method Details
.attributes ⇒ Object
52 |
# File 'lib/top4r/model/user.rb', line 52 def attributes; @@ATTRIBUTES; end |
.default_private_fields ⇒ Object
59 60 61 |
# File 'lib/top4r/model/user.rb', line 59 def default_private_fields ["location.zip", "birthday"] end |
.default_public_fields ⇒ Object
54 55 56 57 |
# File 'lib/top4r/model/user.rb', line 54 def default_public_fields ["user_id", "nick", "sex", "buyer_credit", "seller_credit", "location.city", "location.state", "location.country", "created", "last_visit", "type"] end |
.find(u, client) ⇒ Object
63 64 65 |
# File 'lib/top4r/model/user.rb', line 63 def find(u, client) client.user(u) end |
Instance Method Details
#bless(client) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/top4r/model/user.rb', line 68 def bless(client) basic_bless(client) self.instance_eval(%{ self.class.send(:include, Top4R::LoggedInUserMixin) }) if self.is_me? and not self.respond_to?(:trades) self end |
#is_me? ⇒ Boolean
76 77 78 |
# File 'lib/top4r/model/user.rb', line 76 def is_me? @nick == @client.instance_eval("@parameters['visitor_nick']") end |
#unmarshal_other_attrs ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/top4r/model/user.rb', line 80 def unmarshal_other_attrs @id = @user_id if @location && @location.size > 0 @location = Location.new(@location) else @location = nil end @buyer_credit = UserCredit.new(@buyer_credit) if @buyer_credit && @buyer_credit.size > 0 @seller_credit = UserCredit.new(@seller_credit) if @seller_credit && @seller_credit.size > 0 # @nick = @nick.to_utf8 self end |