Sha256: 083be0158c2019990cac3725f077e5ba7be5ac5b69d63837287b652d81f5f55a
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module OpenTransact # The Asset is the most important concept in OpenTransact. It represents an asset type. class Asset attr_accessor :url, :transaction_url, :client, :options def initialize(url,options={}) @url = url @transaction_url = options[:transaction_url]||@url @client = options[:client] @options = options||{} end # Create a redirect url for a simple web payment # # redirect_to @asset.transfer_url 12, "bob@test.com", "For implementing shopping cart" # def transfer_url(amount,to,memo,options={}) uri = URI.parse(transaction_url) uri.query = URI.escape("amount=#{amount}&to=#{to}&memo=#{memo}") uri.to_s end # Perform a transfer (payment) # # @asset.transfer 12, "bob@test.com", "For implementing shopping cart" # def transfer(amount,to,memo=nil) client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client end def name @options["name"] end def balance @options["balance"] end def [](key) @options[key] if @options end protected def uri @uri ||= URI.parse(url) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opentransact-0.1.1 | lib/opentransact/asset.rb |