Skip to content

Instantly share code, notes, and snippets.

@digitalplaywright
Created March 21, 2012 21:49
Show Gist options
  • Save digitalplaywright/9bfd99af5ad76f81c0d5 to your computer and use it in GitHub Desktop.
Save digitalplaywright/9bfd99af5ad76f81c0d5 to your computer and use it in GitHub Desktop.
using class
AMOUNT_CALC_ATTRIBUTES = [:_, :quantity, :price_per, :subtotal, :service_fee, :total, :currency, :trans_fee]
class AmountCalculated
attr_accessor *AMOUNT_CALC_ATTRIBUTES
def initialize(opts)
opts.each{|k,v| self.send("#{k}=", v)}
end
end
Example call:
am = AmountCalculated.new({ :quantity => 0, :price_per => 0, :subtotal => 0, :service_fee => 0, :trans_fee => 0, :total => 0, :currency => 'USD' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment