class Adyen::HashWithAccessors

Public Instance Methods

method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/adyen/hash_with_accessors.rb, line 8
def method_missing(method, *args)
  string_key = method.to_s.sub(/=\z/, '')
  sym_key = string_key.to_sym

  key = if has_key?(string_key)
    string_key
  elsif has_key?(sym_key)
    sym_key
  end

  return super unless key

  assignment = sym_key != method

  if assignment
    raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1)" unless args.size == 1

    self[key] = args.first
  else
    raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0)" unless args.size == 0

    self[key]
  end
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/adyen/hash_with_accessors.rb, line 33
def respond_to_missing?(method, include_private = false)
  string_key = method.to_s.sub(/=\z/, '')
  has_key?(string_key) || has_key?(string_key.to_sym) || super
end