Class: Datafiniti::User
- Inherits:
-
Object
- Object
- Datafiniti::User
- Includes:
- HTTParty
- Defined in:
- lib/datafiniti/users.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(api_token = ENV['DATAFINITI_API_KEY']) ⇒ User
constructor
A new instance of User.
- #method_missing(name, *args, &block) ⇒ Object
- #profile(force = false) ⇒ Object
Constructor Details
#initialize(api_token = ENV['DATAFINITI_API_KEY']) ⇒ User
Returns a new instance of User.
6 7 8 |
# File 'lib/datafiniti/users.rb', line 6 def initialize(api_token=ENV['DATAFINITI_API_KEY']) self.token = api_token end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19 20 21 22 |
# File 'lib/datafiniti/users.rb', line 19 def method_missing(name, *args, &block) profile.has_key?(name.to_s) ? profile[name.to_s] : super # profile.has_key?(name.to_s) ? profile.send(name.to_sym) : super end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/datafiniti/users.rb', line 4 def token @token end |
Instance Method Details
#profile(force = false) ⇒ Object
15 16 17 |
# File 'lib/datafiniti/users.rb', line 15 def profile(force=false) force ? @profile = get_profile : @profile ||= get_profile end |