dynabute 0.0.8 → 0.0.9
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/dynabute/nested_attributes.rb +18 -1
- data/lib/dynabute/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: ee655aa7af2e497ec5daffa27f3d83db94448ca0
|
4
|
+
data.tar.gz: 53f63f96fe4e2e8e494f232ac624443ba8d261c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b290630301c4acd651d52347b4c738f0f7a2267a6c65ccf9c05074ac3f9067f9b3ff3899be95e83e27f59420e9cc69682f86fa6767359ffdfd3e9650d577d1d7
|
7
|
+
data.tar.gz: ea3e0577fff1409935992c06c69795385f9bdda0338c3d42b32744b3f2fdf02b2a9cd8667a4fdd51fea11190bedfc71600a29a4075775f20dd9c4b94d34d8bf2
|
@@ -5,7 +5,10 @@ module Dynabute
|
|
5
5
|
class FieldNotSpecified < StandardError; end
|
6
6
|
class Builder
|
7
7
|
def initialize(attributes_list, dynabutee)
|
8
|
-
|
8
|
+
unless attributes_list.is_a?(Hash) || attributes_list.is_a?(Array)
|
9
|
+
raise ArgumentError, "Hash or Array expected, got #{attributes_list.class.name} (#{attributes_list.inspect})"
|
10
|
+
end
|
11
|
+
@attributes_list = normalize_attributes(attributes_list)
|
9
12
|
@nested_attributes_to_assign = {}
|
10
13
|
@dynabutee = dynabutee
|
11
14
|
end
|
@@ -41,6 +44,20 @@ module Dynabute
|
|
41
44
|
end
|
42
45
|
|
43
46
|
private
|
47
|
+
|
48
|
+
def normalize_attributes(attributes_list)
|
49
|
+
if attributes_list.is_a? Hash
|
50
|
+
attributes_array = if attributes_list.keys.all?{|k| k =~ /\A\d+\Z/}
|
51
|
+
attributes_list.values
|
52
|
+
else
|
53
|
+
[attributes_list]
|
54
|
+
end
|
55
|
+
else
|
56
|
+
attributes_array = attributes_list
|
57
|
+
end
|
58
|
+
attributes_array.map{ |a| a.with_indifferent_access }
|
59
|
+
end
|
60
|
+
|
44
61
|
def resolve_field(attrs)
|
45
62
|
@field_list.detect{|f| f.name == attrs[:name].to_s || f.id == attrs[:field_id].to_i}
|
46
63
|
end
|
data/lib/dynabute/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynabute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liooo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|