Class: Toolchest::Configuration
- Inherits:
-
Object
- Object
- Toolchest::Configuration
- Defined in:
- lib/toolchest/configuration.rb
Constant Summary collapse
- VALID_AUTH_STRATEGIES =
%i[none token oauth].freeze
Instance Attribute Summary collapse
-
#access_token_expires_in ⇒ Object
Returns the value of attribute access_token_expires_in.
-
#additional_view_paths ⇒ Object
Returns the value of attribute additional_view_paths.
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#filter_tools_by_scope ⇒ Object
Returns the value of attribute filter_tools_by_scope.
-
#login_path ⇒ Object
Returns the value of attribute login_path.
-
#mount_key ⇒ Object
Returns the value of attribute mount_key.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#optional_scopes ⇒ Object
Returns the value of attribute optional_scopes.
-
#required_scopes ⇒ Object
Returns the value of attribute required_scopes.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
-
#server_description ⇒ Object
Returns the value of attribute server_description.
-
#server_instructions ⇒ Object
Returns the value of attribute server_instructions.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#server_version ⇒ Object
Returns the value of attribute server_version.
-
#tool_naming ⇒ Object
Returns the value of attribute tool_naming.
-
#toolbox_module ⇒ Object
Returns the value of attribute toolbox_module.
-
#toolboxes ⇒ Object
Returns the value of attribute toolboxes.
Instance Method Summary collapse
- #allowed_scopes_for(&block) ⇒ Object
- #authenticate(&block) ⇒ Object
- #authenticate_with(token) ⇒ Object
- #authorize_link(&block) ⇒ Object
- #authorize_link?(user) ⇒ Boolean
- #current_user_for_oauth(&block) ⇒ Object
-
#initialize(mount_key = :default) ⇒ Configuration
constructor
A new instance of Configuration.
- #resolve_allowed_scopes(user, scopes) ⇒ Object
- #resolve_current_user(request) ⇒ Object
- #resolved_server_name ⇒ Object
Constructor Details
#initialize(mount_key = :default) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/toolchest/configuration.rb', line 13 def initialize(mount_key = :default) @mount_key = mount_key.to_sym @auth = :none @tool_naming = :underscored @filter_tools_by_scope = true @server_name = nil @server_version = Toolchest::VERSION @scopes = {} @login_path = "/login" @authenticate_block = nil @optional_scopes = false @required_scopes = [] @allowed_scopes_for_block = nil @authorize_link_block = nil @additional_view_paths = [] @access_token_expires_in = 7200 @toolboxes = nil @toolbox_module = nil end |
Instance Attribute Details
#access_token_expires_in ⇒ Object
Returns the value of attribute access_token_expires_in.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def access_token_expires_in @access_token_expires_in end |
#additional_view_paths ⇒ Object
Returns the value of attribute additional_view_paths.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def additional_view_paths @additional_view_paths end |
#auth ⇒ Object
Returns the value of attribute auth.
11 12 13 |
# File 'lib/toolchest/configuration.rb', line 11 def auth @auth end |
#filter_tools_by_scope ⇒ Object
Returns the value of attribute filter_tools_by_scope.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def filter_tools_by_scope @filter_tools_by_scope end |
#login_path ⇒ Object
Returns the value of attribute login_path.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def login_path @login_path end |
#mount_key ⇒ Object
Returns the value of attribute mount_key.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def mount_key @mount_key end |
#mount_path ⇒ Object
Returns the value of attribute mount_path.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def mount_path @mount_path end |
#optional_scopes ⇒ Object
Returns the value of attribute optional_scopes.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def optional_scopes @optional_scopes end |
#required_scopes ⇒ Object
Returns the value of attribute required_scopes.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def required_scopes @required_scopes end |
#scopes ⇒ Object
Returns the value of attribute scopes.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def scopes @scopes end |
#server_description ⇒ Object
Returns the value of attribute server_description.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def server_description @server_description end |
#server_instructions ⇒ Object
Returns the value of attribute server_instructions.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def server_instructions @server_instructions end |
#server_name ⇒ Object
Returns the value of attribute server_name.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def server_name @server_name end |
#server_version ⇒ Object
Returns the value of attribute server_version.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def server_version @server_version end |
#tool_naming ⇒ Object
Returns the value of attribute tool_naming.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def tool_naming @tool_naming end |
#toolbox_module ⇒ Object
Returns the value of attribute toolbox_module.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def toolbox_module @toolbox_module end |
#toolboxes ⇒ Object
Returns the value of attribute toolboxes.
5 6 7 |
# File 'lib/toolchest/configuration.rb', line 5 def toolboxes @toolboxes end |
Instance Method Details
#allowed_scopes_for(&block) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/toolchest/configuration.rb', line 69 def allowed_scopes_for(&block) if block @allowed_scopes_for_block = block else @allowed_scopes_for_block end end |
#authenticate(&block) ⇒ Object
49 |
# File 'lib/toolchest/configuration.rb', line 49 def authenticate(&block) = @authenticate_block = block |
#authenticate_with(token) ⇒ Object
51 52 53 54 |
# File 'lib/toolchest/configuration.rb', line 51 def authenticate_with(token) return nil unless @authenticate_block @authenticate_block.call(token) end |
#authorize_link(&block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/toolchest/configuration.rb', line 56 def (&block) if block @authorize_link_block = block else @authorize_link_block end end |
#authorize_link?(user) ⇒ Boolean
64 65 66 67 |
# File 'lib/toolchest/configuration.rb', line 64 def (user) return true unless @authorize_link_block @authorize_link_block.call(user) end |
#current_user_for_oauth(&block) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/toolchest/configuration.rb', line 81 def current_user_for_oauth(&block) if block @current_user_for_oauth_block = block else @current_user_for_oauth_block end end |
#resolve_allowed_scopes(user, scopes) ⇒ Object
77 78 79 |
# File 'lib/toolchest/configuration.rb', line 77 def resolve_allowed_scopes(user, scopes) @allowed_scopes_for_block ? @allowed_scopes_for_block.call(user, scopes) : scopes end |
#resolve_current_user(request) ⇒ Object
89 90 91 92 |
# File 'lib/toolchest/configuration.rb', line 89 def resolve_current_user(request) return nil unless @current_user_for_oauth_block @current_user_for_oauth_block.call(request) end |
#resolved_server_name ⇒ Object
94 |
# File 'lib/toolchest/configuration.rb', line 94 def resolved_server_name = @server_name || (defined?(Rails) && Rails.application ? Rails.application.class.module_parent_name : "Toolchest") |