Class: Motion::OAuth2::Error
- Inherits:
-
Object
- Object
- Motion::OAuth2::Error
- Defined in:
- lib/motion/oauth2/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#url ⇒ Object
Returns the value of attribute url.
-
#www_authenticate ⇒ Object
Returns the value of attribute www_authenticate.
Instance Method Summary collapse
-
#initialize(body, www_authenticate_header = nil) ⇒ Error
constructor
A new instance of Error.
- #oauth2_error? ⇒ Boolean
Constructor Details
#initialize(body, www_authenticate_header = nil) ⇒ Error
Returns a new instance of Error.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/motion/oauth2/error.rb', line 6 def initialize(body, www_authenticate_header = nil) self.raw = body self.www_authenticate = www_authenticate_header if oauth2_error? self.code = body['error'].to_sym self.description = body['description'] self.url = body['error_url'] else self.code = :unknown end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/motion/oauth2/error.rb', line 4 def code @code end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/motion/oauth2/error.rb', line 4 def description @description end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/motion/oauth2/error.rb', line 4 def raw @raw end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/motion/oauth2/error.rb', line 4 def url @url end |
#www_authenticate ⇒ Object
Returns the value of attribute www_authenticate.
4 5 6 |
# File 'lib/motion/oauth2/error.rb', line 4 def www_authenticate @www_authenticate end |
Instance Method Details
#oauth2_error? ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'lib/motion/oauth2/error.rb', line 18 def oauth2_error? @body.is_a?(Hash) && [ 'invalid_request', 'invalid_token', 'insufficient_scope' ].include?(body[:error]) end |