Class: Net::Facebook::Models::Page
- Inherits:
-
Object
- Object
- Net::Facebook::Models::Page
- Defined in:
- lib/net/facebook/models/page.rb
Instance Attribute Summary collapse
-
#likes ⇒ Object
readonly
Returns the value of attribute likes.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.find_by(params = {}) ⇒ Net::Facebook::Models::Page
Returns the existing Facebook page matching the provided attributes or nil when the page is not found.
-
.find_by!(params = {}) ⇒ Net::Facebook::Models::Page
Returns the existing Facebook page matching the provided attributes or raises an error when the page is not found.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Page
constructor
A new instance of Page.
Constructor Details
#initialize(attrs = {}) ⇒ Page
Returns a new instance of Page.
10 11 12 13 |
# File 'lib/net/facebook/models/page.rb', line 10 def initialize(attrs = {}) @username = attrs['username'] @likes = attrs['likes'] end |
Instance Attribute Details
#likes ⇒ Object (readonly)
Returns the value of attribute likes.
8 9 10 |
# File 'lib/net/facebook/models/page.rb', line 8 def likes @likes end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/net/facebook/models/page.rb', line 8 def username @username end |
Class Method Details
.find_by(params = {}) ⇒ Net::Facebook::Models::Page
Returns the existing Facebook page matching the provided attributes or nil when the page is not found.
@ return [nil] when the page cannot be found.
24 25 26 27 28 |
# File 'lib/net/facebook/models/page.rb', line 24 def self.find_by(params = {}) find_by! params rescue Errors::UnknownUser nil end |
.find_by!(params = {}) ⇒ Net::Facebook::Models::Page
Returns the existing Facebook page matching the provided attributes or raises an error when the page is not found.
38 39 40 41 42 43 44 45 |
# File 'lib/net/facebook/models/page.rb', line 38 def self.find_by!(params = {}) request = Api::Request.new params new request.run rescue Errors::ResponseError => error case error.response when Net::HTTPNotFound then raise Errors::UnknownUser end end |