Class: Unveil::User
- Inherits:
-
Object
- Object
- Unveil::User
- Defined in:
- lib/unveil/user.rb
Instance Method Summary collapse
- #attributes(reload = false) ⇒ Object
-
#initialize(user_id) ⇒ User
constructor
A new instance of User.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(user_id) ⇒ User
Returns a new instance of User.
3 4 5 |
# File 'lib/unveil/user.rb', line 3 def initialize(user_id) @user_id = user_id end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/unveil/user.rb', line 12 def method_missing(method, *args, &block) if attributes.has_key?(method.to_s) attributes(*args)[method.to_s] else super end end |
Instance Method Details
#attributes(reload = false) ⇒ Object
7 8 9 10 |
# File 'lib/unveil/user.rb', line 7 def attributes(reload = false) @attributes = nil if reload @attributes ||= JSON.parse(Unveil.get("users/#{@user_id}").body) end |