Sha256: 5349a209b49b297886b4cb3fcbf3ac071bd985ec0d2222e37992716b8d03783d

Contents?: true

Size: 764 Bytes

Versions: 23

Compression:

Stored size: 764 Bytes

Contents

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

      attr_reader *attr_list

      def initialize(attributes={})
        time_fields = ['price_updated_at']
        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 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

23 entries across 23 versions & 1 rubygems

Version Path
xsys-0.9.2 lib/xsys/model/product_price_list.rb
xsys-0.9.1 lib/xsys/model/product_price_list.rb
xsys-0.9.0 lib/xsys/model/product_price_list.rb
xsys-0.8.7 lib/xsys/model/product_price_list.rb
xsys-0.8.6 lib/xsys/model/product_price_list.rb
xsys-0.8.5 lib/xsys/model/product_price_list.rb
xsys-0.8.4 lib/xsys/model/product_price_list.rb
xsys-0.8.3 lib/xsys/model/product_price_list.rb
xsys-0.8.2 lib/xsys/model/product_price_list.rb
xsys-0.8.1 lib/xsys/model/product_price_list.rb
xsys-0.8.0 lib/xsys/model/product_price_list.rb
xsys-0.7.0 lib/xsys/model/product_price_list.rb
xsys-0.6.5 lib/xsys/model/product_price_list.rb
xsys-0.6.4 lib/xsys/model/product_price_list.rb
xsys-0.6.3 lib/xsys/model/product_price_list.rb
xsys-0.6.2 lib/xsys/model/product_price_list.rb
xsys-0.6.1 lib/xsys/model/product_price_list.rb
xsys-0.6.0 lib/xsys/model/product_price_list.rb
xsys-0.5.2 lib/xsys/model/product_price_list.rb
xsys-0.5.1 lib/xsys/model/product_price_list.rb