watir_model 0.4.6 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/watir_model.rb +19 -2
- data/watir_model.gemspec +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: d4a63d0d44bca88f86db3a5f5a379eacb7e7c1d1
|
4
|
+
data.tar.gz: dfa9f23bfaadb59ed9e24191c6ae4d17fb3b854b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7981185908b815a682f83c7cd33745732aa512fa3681f6561da8ad9aea7d244a9b3d23ecb05a4e6776a3534a2619bc293d9cb4da91a11dc1d9135a0bb4f9f097
|
7
|
+
data.tar.gz: dec2feaa6de866aaa79cc1add9b0e1740e0041a831f1184ac51c092fc58fbb06eea1a6d678bc8a45afc11c84873dbad6c4da9c87c309f675337d5d3233e3a928
|
data/CHANGES.md
CHANGED
data/lib/watir_model.rb
CHANGED
@@ -30,6 +30,10 @@ class WatirModel
|
|
30
30
|
@defaults ||= {}
|
31
31
|
end
|
32
32
|
|
33
|
+
def valid_keys
|
34
|
+
keys + aliases.keys + apis.keys
|
35
|
+
end
|
36
|
+
|
33
37
|
def inherited(subclass)
|
34
38
|
subclass.keys = keys.dup
|
35
39
|
subclass.aliases = aliases.dup
|
@@ -82,7 +86,10 @@ class WatirModel
|
|
82
86
|
|
83
87
|
def convert(hash, *args)
|
84
88
|
hash.deep_symbolize_keys!
|
85
|
-
filtered = hash.select { |k|
|
89
|
+
filtered = hash.select { |k| valid_keys.include?(k) }
|
90
|
+
unless (defaults.keys - default_value_keys(filtered)).empty?
|
91
|
+
raise StandardError, "Can not convert Hash to Model when keys with default values are missing"
|
92
|
+
end
|
86
93
|
model = new(filtered)
|
87
94
|
args.each do |key|
|
88
95
|
model.instance_eval do
|
@@ -96,6 +103,12 @@ class WatirModel
|
|
96
103
|
'config/data'
|
97
104
|
end
|
98
105
|
|
106
|
+
def default_value_keys(hash)
|
107
|
+
hash.keys.map do |key|
|
108
|
+
keys.include?(key) ? key : (aliases[key] || apis[key])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
99
112
|
def method_missing(method, *args, &block)
|
100
113
|
file = factory_file(self)
|
101
114
|
return super unless file
|
@@ -114,7 +127,7 @@ class WatirModel
|
|
114
127
|
end
|
115
128
|
end
|
116
129
|
|
117
|
-
def initialize(hash={})
|
130
|
+
def initialize(hash = {})
|
118
131
|
hash.deep_symbolize_keys!
|
119
132
|
update(hash)
|
120
133
|
|
@@ -158,6 +171,10 @@ class WatirModel
|
|
158
171
|
self.class.apis
|
159
172
|
end
|
160
173
|
|
174
|
+
def valid_keys
|
175
|
+
self.class.apis
|
176
|
+
end
|
177
|
+
|
161
178
|
def [] key
|
162
179
|
send key
|
163
180
|
end
|
data/watir_model.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|