Module: Johac
- Defined in:
- lib/johac.rb,
lib/johac/error.rb,
lib/johac/client.rb,
lib/johac/version.rb,
lib/johac/response.rb,
lib/johac/connection.rb
Defined Under Namespace
Modules: Connection Classes: Client, Config, Error, Response
Constant Summary collapse
- Version =
'0.9.0'
Class Method Summary collapse
-
.config ⇒ Johac::Config
Return the config object for the global Client instance.
-
.defaults {|config| ... } ⇒ Johac::Config
Configure the global defaults for all clients built.
-
.merged_config(overrides) ⇒ Object
Merge the new config with defaults.
Class Method Details
.config ⇒ Johac::Config
Return the config object for the global Client instance.
47 48 49 50 51 52 |
# File 'lib/johac.rb', line 47 def config unless defined? @config raise "#{self.name} not configured. Configure via #{self.name}.configure { |cfg| ... }, or via client constructor" end @config end |
.defaults {|config| ... } ⇒ Johac::Config
Configure the global defaults for all clients built.
38 39 40 41 42 43 |
# File 'lib/johac.rb', line 38 def defaults(&block) c = @config ||= Config.new c.env = environment || 'production' yield c c end |
.merged_config(overrides) ⇒ Object
Merge the new config with defaults
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/johac.rb', line 55 def merged_config(overrides) case overrides when Hash dup_config.tap do |conf| overrides.each do |k, v| conf[k] = v end end when Struct dup_config.tap do |conf| overrides.each_pair do |k, v| conf[k] = v end end else config end end |