Sha256: 3f549a104874092cb822bd212a4fb581874ef4980b8b6ab5511d121a3d7310bc
Contents?: true
Size: 735 Bytes
Versions: 7
Compression:
Stored size: 735 Bytes
Contents
class Hash def to_settings Payanyway::Helpers::Settings.new(self) end end module Payanyway module Helpers class Settings delegate :[], to: '@settings' def initialize(settings) @settings = HashWithIndifferentAccess.new(settings.invert) end # Выбирает из настроек нужные # и подставляет в переданный hash # # @settings = { 'MNT_ID' => :id, 'MNT_CURRENCY' => :currency } # hash = { id: 1 } # => { 'MNT_ID': 1 } def configure_by(hash) hash.each_with_object({}) do |(key, value), memo| memo[ @settings[key] ] = value if @settings.has_key?(key) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems