Sha256: dbcddf820b7a8f841b6fdc7c085a4991dc0f50faab8f05223ff934b03cdc4884

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

module RubyPsigate
  # DOC - TODO
  class Address

    include RubyPsigate::HashVariables
    
    hashable :billing, %w( Bname Bcompany Baddress1 Baddress2 Bcity Bprovince Bpostalcode Bcountry Phone Fax )
    hashable :shipping, %w( Sname Scompany Saddress1 Saddress2 Scity Sprovince Spostalcode Scountry )
        
    attr_accessor :firstname, :lastname, :line1, :line2, :city, :state, :country, :zipcode, :telephone, :fax, :company

    alias_method :province, :state
    alias_method :province=, :state=

    alias_method :postalcode, :zipcode
    alias_method :postalcode=, :zipcode=
    
    alias_method :address1, :line1
    alias_method :address2, :line2
    
    alias_method :phone, :telephone
    
    def name
      "#{firstname} #{lastname}".strip
    end
    
    def to_hash(type = nil)
      result = super
      result = result.delete_if { |key, value| value.nil? }  # Delete empty hash values
      result
    end

    # For billing
    alias_method :bname, :name
    alias_method :bcompany, :company
    alias_method :baddress1, :address1
    alias_method :baddress2, :address2
    alias_method :bcity, :city
    alias_method :bprovince, :province
    alias_method :bpostalcode, :postalcode
    alias_method :bcountry, :country
    
    # For shipping
    alias_method :sname, :name
    alias_method :scompany, :company
    alias_method :saddress1, :address1
    alias_method :saddress2, :address2
    alias_method :scity, :city
    alias_method :sprovince, :province
    alias_method :spostalcode, :postalcode
    alias_method :scountry, :country
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_psigate-0.7.2 lib/ruby_psigate/address.rb
ruby_psigate-0.7.1 lib/ruby_psigate/address.rb
ruby_psigate-0.7 lib/ruby_psigate/address.rb