Class: Unveil::User

Inherits:
Object
  • Object
show all
Defined in:
lib/unveil/user.rb

Instance Method Summary collapse

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