Sha256: 82d52756a909bef4585fe15cb492ff2c51439b0b4eee31c82377783f27ebe111

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

module XeroGateway
  class LineItem
    # All accessible fields
    attr_accessor :line_item_id, :description, :quantity, :unit_amount, :tax_type, :tax_amount, :line_amount, :account_code, :tracking_category, :tracking_option
    
    def initialize(params = {})
      params = {
        :quantity => 1
      }.merge(params)
      
      params.each do |k,v|
        self.instance_variable_set("@#{k}", v)  ## create and initialize an instance variable for this key/value pair
        self.send("#{k}=", v)
      end
    end    

    def ==(other)
      [:description, :quantity, :unit_amount, :tax_type, :tax_amount, :line_amount, :account_code, :tracking_category, :tracking_option].each do |field|
        puts field if send(field) != other.send(field) 
        return false if send(field) != other.send(field)
      end
      return true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tlconnor-xero_gateway-1.0.1 lib/xero_gateway/line_item.rb
tlconnor-xero_gateway-1.0.2 lib/xero_gateway/line_item.rb
tlconnor-xero_gateway-1.0.3 lib/xero_gateway/line_item.rb