Class: MerchantZip::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/merchant-zip/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
# File 'lib/merchant-zip/configuration.rb', line 22

def initialize
  @mode = :live
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/merchant-zip/configuration.rb', line 4

def api_key
  @api_key
end

#modeObject

Returns the value of attribute mode.



3
4
5
# File 'lib/merchant-zip/configuration.rb', line 3

def mode
  @mode
end

Class Method Details

.setupObject



6
7
8
9
10
# File 'lib/merchant-zip/configuration.rb', line 6

def self.setup
  new.tap do |instance|
    yield(instance) if block_given?
  end
end

Instance Method Details

#reverse_duplicate_merge(hash) ⇒ Object

Create a new config based off an existing one. This is useful when the caller wants to override the global configuration



14
15
16
17
18
19
20
# File 'lib/merchant-zip/configuration.rb', line 14

def reverse_duplicate_merge(hash)
  dup.tap do |instance|
    hash.each do |option, value|
      instance.public_send("#{option}=", value)
    end
  end
end