Class: Hungry::User
Instance Attribute Summary collapse
-
#activated_at ⇒ Object
Preview:.
-
#admin ⇒ Object
Preview:.
-
#avatar ⇒ Object
Preview:.
-
#bio ⇒ Object
Preview:.
-
#birth_date ⇒ Object
Preview:.
-
#connections ⇒ Object
Preview:.
-
#counters ⇒ Object
Preview:.
-
#created_at ⇒ Object
Preview:.
-
#device_tokens ⇒ Object
Preview:.
-
#email ⇒ Object
Preview:.
-
#gender ⇒ Object
Preview:.
-
#id ⇒ Object
Preview:.
-
#location ⇒ Object
Preview:.
-
#maintainer_of ⇒ Object
Preview:.
-
#name ⇒ Object
Preview:.
-
#persistence_token ⇒ Object
Preview:.
-
#profile_url ⇒ Object
Preview:.
-
#resources ⇒ Object
Preview:.
-
#score ⇒ Object
Preview:.
-
#single_access_token ⇒ Object
Preview:.
-
#slug ⇒ Object
Preview:.
-
#updated_at ⇒ Object
Preview:.
-
#website_url ⇒ Object
Preview:.
Attributes inherited from Resource
Class Method Summary collapse
- .authenticate_via_api(options = {}) ⇒ Object
- .authenticate_with_perishable_token(perishable_token) ⇒ Object
-
.authenticate_with_persistence_token(persistence_token) ⇒ Object
CLASS METHODS:.
- .from_json(json) ⇒ Object
-
.with_ip(ip_address) ⇒ Object
FINDERS:.
Methods inherited from Resource
all, belongs_to, #canonical_data_source, collection, each, find, first, get, has_many, #initialize, lazy_load, #reload
Constructor Details
This class inherits a constructor from Hungry::Resource
Instance Attribute Details
#activated_at ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def activated_at @activated_at end |
#admin ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def admin @admin end |
#avatar ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def avatar @avatar end |
#bio ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def bio @bio end |
#birth_date ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def birth_date @birth_date end |
#connections ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def connections @connections end |
#counters ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def counters @counters end |
#created_at ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def created_at @created_at end |
#device_tokens ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def device_tokens @device_tokens end |
#email ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def email @email end |
#gender ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def gender @gender end |
#id ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def id @id end |
#location ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def location @location end |
#maintainer_of ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def maintainer_of @maintainer_of end |
#name ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def name @name end |
#persistence_token ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def persistence_token @persistence_token end |
#profile_url ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def profile_url @profile_url end |
#resources ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def resources @resources end |
#score ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def score @score end |
#single_access_token ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def single_access_token @single_access_token end |
#slug ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def slug @slug end |
#updated_at ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def updated_at @updated_at end |
#website_url ⇒ Object
Preview:
65 66 67 |
# File 'lib/hungry/user.rb', line 65 def website_url @website_url end |
Class Method Details
.authenticate_via_api(options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hungry/user.rb', line 36 def self.authenticate_via_api( = {}) = { path: '/account.json', query: nil }.merge() url = URI.parse(Hungry.api_url) url.path = .delete(:path) url.query = .delete(:query) http = Net::HTTP.new(url.host, url.port) if url.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end request = Net::HTTP::Get.new(url.request_uri, ) response = http.request request if response.code.to_i == 200 response.body else false end end |
.authenticate_with_perishable_token(perishable_token) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/hungry/user.rb', line 25 def self.authenticate_with_perishable_token(perishable_token) result = authenticate_via_api query: "perishable_token=#{perishable_token}" return false unless result.present? from_json(result) end |
.authenticate_with_persistence_token(persistence_token) ⇒ Object
CLASS METHODS:
18 19 20 21 22 23 |
# File 'lib/hungry/user.rb', line 18 def self.authenticate_with_persistence_token(persistence_token) result = authenticate_via_api 'Cookie' => "persistence_token=#{persistence_token}" return false unless result.present? from_json(result) end |
.from_json(json) ⇒ Object
32 33 34 |
# File 'lib/hungry/user.rb', line 32 def self.from_json(json) new Util.parse_json(json) end |
.with_ip(ip_address) ⇒ Object
FINDERS:
12 13 14 |
# File 'lib/hungry/user.rb', line 12 def self.with_ip(ip_address) collection.all(ip: ip_address) end |