Class: Net::Facebook::Models::User
- Inherits:
-
Object
- Object
- Net::Facebook::Models::User
- Defined in:
- lib/net/facebook/models/user.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
Class Method Summary collapse
-
.find_by(params = {}) ⇒ Net::Facebook::Models::User
Returns the existing Facebook user matching the provided attributes or nil when the user is not found.
-
.find_by!(params = {}) ⇒ Net::Facebook::Models::User
Returns the existing Facebook user matching the provided attributes or raises an error when the user is not found.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ User
constructor
A new instance of User.
- #pages ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ User
Returns a new instance of User.
10 11 12 13 14 15 16 17 |
# File 'lib/net/facebook/models/user.rb', line 10 def initialize(attrs = {}) @id = attrs['id'] @email = attrs['email'] @gender = attrs['gender'] @first_name = attrs['first_name'] @last_name = attrs['last_name'] @access_token = attrs['access_token'] end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def access_token @access_token end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def first_name @first_name end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def gender @gender end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def id @id end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
8 9 10 |
# File 'lib/net/facebook/models/user.rb', line 8 def last_name @last_name end |
Class Method Details
.find_by(params = {}) ⇒ Net::Facebook::Models::User
Returns the existing Facebook user matching the provided attributes or nil when the user is not found.
@ return [nil] when the user cannot be found.
35 36 37 38 39 |
# File 'lib/net/facebook/models/user.rb', line 35 def self.find_by(params = {}) find_by! params rescue Errors::UnknownUser nil end |
.find_by!(params = {}) ⇒ Net::Facebook::Models::User
Returns the existing Facebook user matching the provided attributes or raises an error when the user is not found.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/net/facebook/models/user.rb', line 51 def self.find_by!(params = {}) request = Api::Request.new params if params[:access_token] new request.run.merge!({"access_token" => params[:access_token]}) else new request.run end rescue Errors::ResponseError => error case error.response when Net::HTTPNotFound then raise Errors::UnknownUser end end |