Class: Payanyway::Helpers::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/payanyway/helpers/settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Settings

Returns a new instance of Settings.



12
13
14
# File 'lib/payanyway/helpers/settings.rb', line 12

def initialize(settings)
  @settings = HashWithIndifferentAccess.new(settings.invert)
end

Instance Method Details

#configure_by(hash) ⇒ Object

Выбирает из настроек нужные и подставляет в переданный hash

@settings = { 'MNT_ID' => :id, 'MNT_CURRENCY' => :currency }
hash = { id: 1 }
=> { 'MNT_ID': 1 }


22
23
24
25
26
# File 'lib/payanyway/helpers/settings.rb', line 22

def configure_by(hash)
  hash.each_with_object({}) do |(key, value), memo|
    memo[ @settings[key] ] = value if @settings.has_key?(key)
  end
end