Sha256: f2e9c65053197ed29c9dd9deab468c71d09a1b0c5f4eeda7a6d8e268f57cac80

Contents?: true

Size: 935 Bytes

Versions: 20

Compression:

Stored size: 935 Bytes

Contents

module Xsys
  module Model
    class ProductPriceList
      def self.attr_list
        [:product_id, :product_name, :price_list_id, :total_price,
         :markup, :price_update_date, :price_update_time]
      end

      attr_reader *attr_list

      def initialize(attributes={})
        time_fields = ['price_update_time']
        date_fields = ['price_update_date']
        decimal_fields = ['total_price']

        attributes.each do |k, v|
          if time_fields.include?(k.to_s)
            self.send("#{k}=", Time.parse(v)) unless v.nil?
          elsif date_fields.include?(k.to_s)
            self.send("#{k}=", Date.parse(v)) unless v.nil?
          elsif decimal_fields.include?(k.to_s)
            self.send("#{k}=", BigDecimal.new(v)) unless v.nil?
          else
            self.send("#{k}=", v) if self.respond_to?(k)
          end
        end
      end

      private

      attr_writer *attr_list
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
xsys-0.17.2 lib/xsys/model/product_price_list.rb
xsys-0.17.1 lib/xsys/model/product_price_list.rb
xsys-0.17.0 lib/xsys/model/product_price_list.rb
xsys-0.16.1 lib/xsys/model/product_price_list.rb
xsys-0.16.0 lib/xsys/model/product_price_list.rb
xsys-0.15.4 lib/xsys/model/product_price_list.rb
xsys-0.15.3 lib/xsys/model/product_price_list.rb
xsys-0.15.2 lib/xsys/model/product_price_list.rb
xsys-0.15.1 lib/xsys/model/product_price_list.rb
xsys-0.15.0 lib/xsys/model/product_price_list.rb
xsys-0.14.0 lib/xsys/model/product_price_list.rb
xsys-0.13.1 lib/xsys/model/product_price_list.rb
xsys-0.13.0 lib/xsys/model/product_price_list.rb
xsys-0.12.0 lib/xsys/model/product_price_list.rb
xsys-0.11.1 lib/xsys/model/product_price_list.rb
xsys-0.10.4 lib/xsys/model/product_price_list.rb
xsys-0.10.3 lib/xsys/model/product_price_list.rb
xsys-0.10.2 lib/xsys/model/product_price_list.rb
xsys-0.10.1 lib/xsys/model/product_price_list.rb
xsys-0.10.0 lib/xsys/model/product_price_list.rb