d_struct 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44d2409d6e32c4db67d6177a56e95256c0a72d41
4
- data.tar.gz: 111559d2c1675f950ea5efee6b4a2334eef1e9dc
3
+ metadata.gz: 955ce746c5eb2da4c34f21c12547bf871b22aca2
4
+ data.tar.gz: 17e3f24cde72948026f513eb039406d2255be317
5
5
  SHA512:
6
- metadata.gz: 74076d4f0a020913f7e15290a33e4f13ca9192313b353947887e7f7fbf1e764488d8f58f6002c21b02d907c2eb104cce41c5854ea41adc4af678590c5bf8e13a
7
- data.tar.gz: 4068d291ffa1438324dc838996e4402e22c0d41d36f986989878459d69af6b3f74c2a89c146dd6a132dac8bf6f9a903c8936cb3319332722c62f95129a90e6e2
6
+ metadata.gz: 0ca610301ff7d6411ddf866a5b57e351c471340f5e8e82f59fe9862e4937c6a7137f5ffb6d207675a6fe9d34f3d6c674d99585449c701e63eda926a62009579c
7
+ data.tar.gz: d22228635053a6da52edcf9b5912aa551de2b6aecb1c18150eee10e4d714c3a43a3b6fbfee17751d92ed102a9d798430f11780635f4d06c1704da0b5b11ac94f
@@ -9,9 +9,10 @@ module DStruct
9
9
  @attributes_readers = attributes_hash.values.flatten
10
10
  @string_attributes = attributes_hash[:strings] || []
11
11
  @integer_attributes = attributes_hash[:integers] || []
12
- @boolean_attributes = attributes_hash[:booleans] || []
12
+ @boolean_attributes = attributes_hash[:booleans] || []
13
13
  @array_attributes = attributes_hash[:arrays] || []
14
14
  @date_attributes = attributes_hash[:dates] || []
15
+ @time_attributes = attributes_hash[:times] || []
15
16
 
16
17
  # generate readers
17
18
  attr_reader *@attributes_readers
@@ -57,6 +58,14 @@ module DStruct
57
58
  @to_h[date_attr] = value
58
59
  end
59
60
  end
61
+
62
+ @time_attributes.each do |time_attr|
63
+ define_method "#{time_attr}=" do |time_arg|
64
+ value = (Time.parse(time_arg.to_s) rescue nil)
65
+ instance_variable_set("@#{time_attr}", value)
66
+ @to_h[time_attr] = value
67
+ end
68
+ end
60
69
  end
61
70
 
62
71
  def add_validation_schema(*schema)
@@ -1,3 +1,3 @@
1
1
  module DStruct
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: d_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damir Roso
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler