Module: Bluepay::Parameters

Included in:
BankAccount, Base, Card, Interface
Defined in:
lib/bluepay/parameters.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DEFAULT_CONVERTER =
->(value) { value.to_s }
BOOLEAN_CONVERTER =
->(value) {
  case value
  when TrueClass then '1'
  when FalseClass then '0'
  else
    value
  end
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



14
15
16
17
# File 'lib/bluepay/parameters.rb', line 14

def self.included(receiver)
  receiver.attr_writer :params
  receiver.extend ClassMethods
end

Instance Method Details

#bluepay_paramsObject



54
55
56
57
58
59
60
# File 'lib/bluepay/parameters.rb', line 54

def bluepay_params
  converted_params.inject(Hash.new) {|memo, kv|
    k, v = kv
    memo[k.to_s.upcase] = v
    memo
  }
end

#converted_paramsObject



46
47
48
49
50
51
52
# File 'lib/bluepay/parameters.rb', line 46

def converted_params
  params.inject(Hash.new) {|memo, kv|
    k, v = kv
    memo[k] = self.class.convert!(k, v)
    memo
  }
end

#paramsObject



42
43
44
# File 'lib/bluepay/parameters.rb', line 42

def params
  @params ||= Hash.new
end