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 +4 -4
- data/lib/d_struct/d_struct.rb +10 -1
- data/lib/d_struct/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 955ce746c5eb2da4c34f21c12547bf871b22aca2
|
4
|
+
data.tar.gz: 17e3f24cde72948026f513eb039406d2255be317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ca610301ff7d6411ddf866a5b57e351c471340f5e8e82f59fe9862e4937c6a7137f5ffb6d207675a6fe9d34f3d6c674d99585449c701e63eda926a62009579c
|
7
|
+
data.tar.gz: d22228635053a6da52edcf9b5912aa551de2b6aecb1c18150eee10e4d714c3a43a3b6fbfee17751d92ed102a9d798430f11780635f4d06c1704da0b5b11ac94f
|
data/lib/d_struct/d_struct.rb
CHANGED
@@ -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
|
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)
|
data/lib/d_struct/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|