Class: CoverMyMeds::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- CoverMyMeds::Railtie
- Defined in:
- lib/cover_my_meds/railtie.rb
Instance Method Summary collapse
-
#configured_client(api_id, secret = nil) ⇒ Object
Create a configured API client class with the configuration stored on the app.
-
#default_client ⇒ Object
Create (and cache) a configured API client instance using the id/secret stored in ‘Rails.application.secrets` and the configuration specified here and in `Rails.application.config.cover_my_meds`.
Instance Method Details
#configured_client(api_id, secret = nil) ⇒ Object
Create a configured API client class with the configuration stored on the app. Useful if you want to use the same host/path configuration as the rest of the app, but a different id/secret pair
17 18 19 20 21 22 23 |
# File 'lib/cover_my_meds/railtie.rb', line 17 def configured_client(api_id, secret = nil) CoverMyMeds::Client.new api_id, secret do |client| config.cover_my_meds.each do |k,v| client.send "#{k}=".to_sym, v end end end |
#default_client ⇒ Object
Create (and cache) a configured API client instance using the id/secret stored in ‘Rails.application.secrets` and the configuration specified here and in `Rails.application.config.cover_my_meds`
10 11 12 |
# File 'lib/cover_my_meds/railtie.rb', line 10 def default_client @client ||= configured_client *credentials end |