Module: Hull::Config
- Included in:
- Hull
- Defined in:
- lib/hull/config.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- DEFAULT_ADAPTER =
The HTTP connection adapter that will be used to connect if none is set
:net_http
- DEFAULT_CONNECTION_OPTIONS =
The Faraday connection options if none is set
{}
- DEFAULT_APP_SECRET =
The client ID if none is set
ENV['HULL_APP_SECRET']
- DEFAULT_APP_ID =
ENV['HULL_APP_ID']
- DEFAULT_ORG_URL =
The ORG_URL that will be used to connect if none is set
ENV['HULL_ORG_URL']
- DEFAULT_JS_URL =
ENV['HULL_JS_URL']
- DEFAULT_CACHE_STORE =
nil
- DEFAULT_PROXY =
nil
- DEFAULT_USER_AGENT =
The value sent in the ‘User-Agent’ header if none is set
"Hull Ruby Gem #{Hull::VERSION}"
- DEFAULT_LOGGER =
nil
- DEFAULT_CURRENT_USER =
Proc.new { self.respond_to?(:current_user) ? current_user : @user }
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Hull::Client
[ :proxy, :adapter, :connection_options, :app_id, :app_secret, :org_url, :user_agent, :cache_store, :logger, :current_user, :user_id, :access_token, :authenticate_users, :user_attributes, :js_url ]
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.
- #domain ⇒ Object
-
#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
61 62 63 |
# File 'lib/hull/config.rb', line 61 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
66 67 68 69 |
# File 'lib/hull/config.rb', line 66 def configure yield self self end |
#domain ⇒ Object
56 57 58 |
# File 'lib/hull/config.rb', line 56 def domain @domain ||= URI.parse(org_url).host unless org_url.nil? end |
#options ⇒ Object
Create a hash of options and their values
72 73 74 75 76 |
# File 'lib/hull/config.rb', line 72 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all configuration options to defaults
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/hull/config.rb', line 79 def reset @domain = nil self.proxy = DEFAULT_PROXY self.logger = DEFAULT_LOGGER self.adapter = DEFAULT_ADAPTER self. = DEFAULT_CONNECTION_OPTIONS self.app_id = DEFAULT_APP_ID self.app_secret = DEFAULT_APP_SECRET self.org_url = DEFAULT_ORG_URL self.js_url = DEFAULT_JS_URL self.user_agent = DEFAULT_USER_AGENT self.cache_store = DEFAULT_CACHE_STORE self.current_user = DEFAULT_CURRENT_USER self.authenticate_users = false self end |