Module: Ubiquitously::Account::Authorizable::InstanceMethods
- Defined in:
- lib/ubiquitously/models/service/account/authorizable.rb
Instance Method Summary collapse
- #authorize(condition) ⇒ Object
- #authorize!(condition) ⇒ Object
- #authorized? ⇒ Boolean
- #logged_in? ⇒ Boolean
- #requires_credentials? ⇒ Boolean
- #uses?(protocol) ⇒ Boolean
Instance Method Details
#authorize(condition) ⇒ Object
33 34 35 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 33 def (condition) @logged_in = !!condition end |
#authorize!(condition) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 23 def (condition) (condition) unless logged_in? raise AuthenticationError.new("Invalid username or password for #{service.titleize}") end logged_in? end |
#authorized? ⇒ Boolean
49 50 51 52 53 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 49 def return true if logged_in? return (credentials? && ) if requires_credentials? return end |
#logged_in? ⇒ Boolean
37 38 39 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 37 def logged_in? @logged_in == true end |
#requires_credentials? ⇒ Boolean
45 46 47 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 45 def requires_credentials? uses?(:oauth) end |
#uses?(protocol) ⇒ Boolean
41 42 43 |
# File 'lib/ubiquitously/models/service/account/authorizable.rb', line 41 def uses?(protocol) self.class.uses?(protocol) end |