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, :avatar, :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, :alipay_account, :alipay_no, :email, :magazine_subscribe, :vertical_market]
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
76 |
# File 'lib/top4r/model/user.rb', line 76 def attributes; @@ATTRIBUTES; end |
.default_private_fields ⇒ Object
83 84 85 |
# File 'lib/top4r/model/user.rb', line 83 def default_private_fields ["location.zip", "birthday", "avatar", "email"] end |
.default_public_fields ⇒ Object
78 79 80 81 |
# File 'lib/top4r/model/user.rb', line 78 def default_public_fields ["user_id", "nick", "sex", "buyer_credit", "seller_credit", "location.city", "location.state", "email", "location.country", "created", "last_visit", "type"] end |
.find(u, client) ⇒ Object
87 88 89 |
# File 'lib/top4r/model/user.rb', line 87 def find(u, client) client.user(u) end |
Instance Method Details
#bless(client) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/top4r/model/user.rb', line 92 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
100 101 102 |
# File 'lib/top4r/model/user.rb', line 100 def is_me? @nick == @client.instance_eval("@parameters['visitor_nick']") end |
#unmarshal_other_attrs ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/top4r/model/user.rb', line 104 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 self end |