Sha256: 8c7239317d7c0aaf236cab670209b137565ca981b4b4571ac81dbb69e31f1a4c
Contents?: true
Size: 646 Bytes
Versions: 1
Compression:
Stored size: 646 Bytes
Contents
module Xsys module Model class ProductPackage def self.attr_list [:length, :width, :height, :weight, :ean] end attr_reader *attr_list def initialize(attributes={}) attributes.each do |k, v| decimal_fields = ['length', 'width', 'height', 'weight'] if 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 def volume length * width * height end private attr_writer *attr_list end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xsys-0.30.0 | lib/xsys/model/product_package.rb |