Module: RubyInstagram::Configuration
- Included in:
- RubyInstagram
- Defined in:
- lib/ruby_instagram/configuration.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a API
%i[ access_token app_id app_secret scope connection_options redirect_uri endpoint user_agent ].freeze
- DEFAULT_ACCESS_TOKEN =
By default, don’t set a user access token
nil
- DEFAULT_APP_ID =
By default, don’t set an application ID
nil
- DEFAULT_APP_SECRET =
By default, don’t set an application secret
nil
- DEFAULT_CONNECTION_OPTIONS =
By default, don’t set any connection options
{}.freeze
- DEFAULT_ENDPOINT =
Note:
There is no reason to use any other endpoint at this time
The endpoint that will be used to connect if none is set
'https://graph.instagram.com/'
- DEFAULT_REDIRECT_URI =
By default, don’t set an application redirect uri
nil
- DEFAULT_SCOPE =
By default, don’t set a user scope
'user_profile'
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set
"Instagram Ruby Gem #{RubyInstagram::VERSION}"
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
51 52 53 |
# File 'lib/ruby_instagram/configuration.rb', line 51 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
56 57 58 |
# File 'lib/ruby_instagram/configuration.rb', line 56 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
61 62 63 64 65 |
# File 'lib/ruby_instagram/configuration.rb', line 61 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Reset all configuration options to defaults
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby_instagram/configuration.rb', line 68 def reset self.access_token = DEFAULT_ACCESS_TOKEN self.app_id = DEFAULT_APP_ID self.app_secret = DEFAULT_APP_SECRET self. = DEFAULT_CONNECTION_OPTIONS self.scope = DEFAULT_SCOPE self.redirect_uri = DEFAULT_REDIRECT_URI self.endpoint = DEFAULT_ENDPOINT self.user_agent = DEFAULT_USER_AGENT end |