module PayPoint::Blue::PayloadBuilder::ClassMethods

Class level methods for PayloadBuilder.

Attributes

shortcuts[W]

Public Instance Methods

shortcut(key, path = nil) click to toggle source

Define a payload shortcut

Shortcuts help payload construction by defining short aliases to commonly used paths.

@example Define and use a shortcut

class PayPoint::Blue::Hosted
  shortcut :amount, "transaction.money.amount.fixed"
end
blue.make_payment(amount: "3.49", ...)
  # this will be turned into
  # { transaction: { money: { amount: { fixed: "3.49" } } } }

@param [Symbol] key the shortcut key @param [String] path a path into the payload with segments

separated by dots (e.g. +'transaction.money.amount.fixed'+)
# File lib/paypoint/blue/payload_builder.rb, line 35
def shortcut(key, path = nil)
  if path.nil?
    shortcuts[key]
  else
    shortcuts[key] = path
  end
end
shortcuts() click to toggle source
# File lib/paypoint/blue/payload_builder.rb, line 13
def shortcuts
  @shortcuts ||= {}
end