Class: InstagramConnect::Configuration
- Inherits:
-
Object
- Object
- InstagramConnect::Configuration
- Defined in:
- lib/instagram_connect/configuration.rb
Overview
Host-facing configuration, set via InstagramConnect.configure { |c| ... }.
auth_path selects which Meta login flow + Graph host the gem talks to:
:instagram_login -> graph.instagram.com, no Facebook Page required
:facebook_login -> graph.facebook.com, requires a linked Facebook Page
Secrets fall back to ENV so a host can configure entirely through the environment (e.g. container secrets) without an initializer edit.
Constant Summary collapse
- AUTH_PATHS =
%i[instagram_login facebook_login].freeze
Instance Attribute Summary collapse
-
#after_connect_redirect ⇒ Object
Returns the value of attribute after_connect_redirect.
-
#allowed_media_types ⇒ Object
Returns the value of attribute allowed_media_types.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
Returns the value of attribute app_secret.
-
#auth_path ⇒ Object
Returns the value of attribute auth_path.
-
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
-
#current_user_id_resolver ⇒ Object
Returns the value of attribute current_user_id_resolver.
-
#default_per_page ⇒ Object
Returns the value of attribute default_per_page.
-
#encrypt_tokens ⇒ Object
Returns the value of attribute encrypt_tokens.
-
#graph_version ⇒ Object
Returns the value of attribute graph_version.
-
#inherit_host_layout ⇒ Object
Returns the value of attribute inherit_host_layout.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#media_max_bytes ⇒ Object
Returns the value of attribute media_max_bytes.
-
#on_comment ⇒ Object
Returns the value of attribute on_comment.
-
#on_message ⇒ Object
Returns the value of attribute on_message.
-
#on_postback ⇒ Object
Returns the value of attribute on_postback.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#verify_token ⇒ Object
Returns the value of attribute verify_token.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#validate! ⇒ Object
Called by .configure at boot.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/instagram_connect/configuration.rb', line 23 def initialize @auth_path = (ENV["INSTAGRAM_CONNECT_AUTH_PATH"] || "instagram_login").to_sym @app_id = ENV["INSTAGRAM_CONNECT_APP_ID"] || ENV["INSTAGRAM_APP_ID"] @app_secret = ENV["INSTAGRAM_CONNECT_APP_SECRET"] || ENV["INSTAGRAM_APP_SECRET"] @verify_token = ENV["INSTAGRAM_CONNECT_VERIFY_TOKEN"] || ENV["INSTAGRAM_VERIFY_TOKEN"] @graph_version = ENV.fetch("INSTAGRAM_CONNECT_GRAPH_VERSION", "v21.0") @redirect_uri = ENV["INSTAGRAM_CONNECT_REDIRECT_URI"] @encrypt_tokens = true @parent_controller = "::ApplicationController" @authenticate_with = nil @current_user_id_resolver = -> { respond_to?(:current_user) && current_user ? current_user.id : nil } @on_message = nil @on_comment = nil @on_postback = nil @logger = Logger.new($stdout) @default_per_page = 25 @inherit_host_layout = true # Where the OAuth callback redirects after connecting an account. @after_connect_redirect = "/" @media_max_bytes = 25 * 1024 * 1024 @allowed_media_types = %w[ image/jpeg image/png image/gif image/webp video/mp4 audio/mpeg audio/aac application/pdf ].freeze end |
Instance Attribute Details
#after_connect_redirect ⇒ Object
Returns the value of attribute after_connect_redirect.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def after_connect_redirect @after_connect_redirect end |
#allowed_media_types ⇒ Object
Returns the value of attribute allowed_media_types.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def allowed_media_types @allowed_media_types end |
#app_id ⇒ Object
Returns the value of attribute app_id.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def app_id @app_id end |
#app_secret ⇒ Object
Returns the value of attribute app_secret.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def app_secret @app_secret end |
#auth_path ⇒ Object
Returns the value of attribute auth_path.
21 22 23 |
# File 'lib/instagram_connect/configuration.rb', line 21 def auth_path @auth_path end |
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def authenticate_with @authenticate_with end |
#current_user_id_resolver ⇒ Object
Returns the value of attribute current_user_id_resolver.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def current_user_id_resolver @current_user_id_resolver end |
#default_per_page ⇒ Object
Returns the value of attribute default_per_page.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def default_per_page @default_per_page end |
#encrypt_tokens ⇒ Object
Returns the value of attribute encrypt_tokens.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def encrypt_tokens @encrypt_tokens end |
#graph_version ⇒ Object
Returns the value of attribute graph_version.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def graph_version @graph_version end |
#inherit_host_layout ⇒ Object
Returns the value of attribute inherit_host_layout.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def inherit_host_layout @inherit_host_layout end |
#logger ⇒ Object
Returns the value of attribute logger.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def logger @logger end |
#media_max_bytes ⇒ Object
Returns the value of attribute media_max_bytes.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def media_max_bytes @media_max_bytes end |
#on_comment ⇒ Object
Returns the value of attribute on_comment.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def on_comment @on_comment end |
#on_message ⇒ Object
Returns the value of attribute on_message.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def @on_message end |
#on_postback ⇒ Object
Returns the value of attribute on_postback.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def on_postback @on_postback end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def parent_controller @parent_controller end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def redirect_uri @redirect_uri end |
#verify_token ⇒ Object
Returns the value of attribute verify_token.
15 16 17 |
# File 'lib/instagram_connect/configuration.rb', line 15 def verify_token @verify_token end |
Instance Method Details
#validate! ⇒ Object
Called by .configure at boot. Validates only structural config (a known auth_path) so an unconfigured host can still boot; secret presence is enforced lazily at the point of use (Client / OAuth).
58 59 60 61 62 63 64 |
# File 'lib/instagram_connect/configuration.rb', line 58 def validate! unless AUTH_PATHS.include?(auth_path) raise ConfigurationError, "auth_path must be one of #{AUTH_PATHS.join(', ')} (got #{auth_path.inspect})" end true end |