Module: MxitApi::ControllerExtensions
- Defined in:
- lib/mxit_api/controller_extensions.rb
Instance Method Summary collapse
-
#load_mxit_auth_token(type) ⇒ Object
type = :user | :app.
- #mxit_api ⇒ Object
-
#save_mxit_auth_token(type, auth_token) ⇒ Object
type = :user | :app.
Instance Method Details
#load_mxit_auth_token(type) ⇒ Object
type = :user | :app
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mxit_api/controller_extensions.rb', line 11 def load_mxit_auth_token type auth_tokens = session[:mxit_auth_tokens] if auth_tokens auth_token = auth_tokens[type] if auth_token and not auth_token.has_expired? return auth_token end end nil end |
#mxit_api ⇒ Object
3 4 5 6 7 8 |
# File 'lib/mxit_api/controller_extensions.rb', line 3 def mxit_api @mxit_api ||= begin client = MxitApi::Client.new(MxitApi.config.mxit_app_name, MxitApi.config.mxit_api_client_id, MxitApi.config.mxit_api_client_secret) end end |
#save_mxit_auth_token(type, auth_token) ⇒ Object
type = :user | :app
24 25 26 27 |
# File 'lib/mxit_api/controller_extensions.rb', line 24 def save_mxit_auth_token type, auth_token auth_tokens = (session[:mxit_auth_tokens] ||= {}) auth_tokens[type] = auth_token end |