xsys 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84e530464b5e72393630467f4e2f79e495b6e4d5
4
- data.tar.gz: bdfa2f7f6dbebb5fc356e42b4a71226c6356c2ce
3
+ metadata.gz: 018ce2777fcf2bb69ed9892c1302e3a46413b125
4
+ data.tar.gz: e70a51e7c55e951164957c0217052510a6fe8428
5
5
  SHA512:
6
- metadata.gz: a460c5892ba725349f078a065942f367503f81a5c7122fe093ed14bdd772008cb800588d4bad5c6b913bb5a20c0badd58de81881b5972f98c75c1008142f2b5d
7
- data.tar.gz: d437cb489e927793c1d9122facb68db2258e27c43792adc8c0142de2b2b218abc4de7be4aad9c6571956c4119530fb7f42f4e24e6b555f415e905a1b44e9994b
6
+ metadata.gz: 9930cb166e252bd41eddb36f567b5e3894ef89abfc5aa4ec54b54bd80066eadbdf9a9c0d1cc4bcf722d4d478d00d1090a4b0e4f70f68bebe180b9b900b18161d
7
+ data.tar.gz: 4e70c12334374bec3cf79683f499529f6c79a3e79051ff9e5930fdf71f0644f6824ac52dd97926cbbd959bf8776e832b6947112568dc5796de79739035dc0200
data/CHANGELOG.md CHANGED
@@ -189,3 +189,7 @@
189
189
  ## v0.3.2
190
190
 
191
191
  * Fixed cases when nil product provider or product category
192
+
193
+ ## v0.4.0
194
+
195
+ * Added support for bigdecimal fields
@@ -11,6 +11,10 @@ module Xsys
11
11
  attr_reader *attr_list
12
12
 
13
13
  def initialize(attributes={})
14
+ time_fields = ['cost_updated_at', 'last_cost_updated_at', 'price_updated_at']
15
+ decimal_fields = ['vat_rate', 'taxed_cost', 'vat_cost', 'total_cost'
16
+ 'last_total_cost']
17
+
14
18
  attributes.each do |k, v|
15
19
  if k.to_s == 'category'
16
20
  @category = ProductCategory.new(v) unless v.nil?
@@ -20,8 +24,10 @@ module Xsys
20
24
  @stocks = v.map { |s| Stock.new(s) } unless v.nil?
21
25
  elsif k.to_s == 'prices'
22
26
  @prices = v.map { |s| ProductPriceList.new(s) }
23
- elsif ['cost_updated_at', 'last_cost_updated_at', 'price_updated_at'].include?(k.to_s)
24
- self.send("#{k}=", Time.parse(v)) unless v.nil?
27
+ elsif time_fields.include?(k.to_s)
28
+ self.send("#{k}=", Time.parse(v)) unless v.nil?
29
+ elsif decimal_fields.include?(k.to_s)
30
+ self.send("#{k}=", BigDecimal.new(v)) unless v.nil?
25
31
  else
26
32
  self.send("#{k}=", v) if self.respond_to?(k)
27
33
  end
@@ -9,9 +9,14 @@ module Xsys
9
9
  attr_reader *attr_list
10
10
 
11
11
  def initialize(attributes={})
12
+ time_fields = ['price_updated_at']
13
+ decimal_fields = ['total_price']
14
+
12
15
  attributes.each do |k, v|
13
- if k.to_s == 'price_updated_at'
14
- @price_updated_at = Time.parse(v) unless v.nil?
16
+ if time_fields.include?(k.to_s)
17
+ self.send("#{k}=", Time.parse(v)) unless v.nil?
18
+ elsif decimal_fields.include?(k.to_s)
19
+ self.send("#{k}=", BigDecimal.new(v)) unless v.nil?
15
20
  else
16
21
  self.send("#{k}=", v) if self.respond_to?(k)
17
22
  end
data/lib/xsys/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xsys
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler