Sha256: 3f60c02bb32e66a1a82bd98a25a9b1676ba432c5cf40efca0438d9066de11ee2

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

Contents

module Stellar
  PaymentOp.class_eval do

    def self.native(amount)
      currency = Stellar::Currency.new(:native)
      with_currency(currency).tap do |result|
        result.amount   = amount
        result.send_max = amount
      end
    end

    def self.iso4217(code, issuer, amount)
      currency = Stellar::Currency.iso4217(code, issuer)
      with_currency(currency).tap do |result|
        result.amount   = amount
        result.send_max = amount
      end
    end

    def self.with_currency(currency)
      new.tap do |result|
        result.currency = currency
        result.path     = []
      end
    end

    def apply_defaults
      self.source_memo ||= ""
      self.memo ||= ""
    end

    def to_operation(source_account=nil)
      body = Operation::Body.new(:payment, self)
      Operation.new(source_account: source_account, body:body)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stellar-base-0.0.2 lib/stellar/payment_op.rb
stellar-base-0.0.1 lib/stellar/payment_op.rb