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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92054e63cf6a05770786b015592d843470930ebd
4
- data.tar.gz: 98c3c14aa3d096c5c0801fd88f3b378f8427779a
3
+ metadata.gz: ee655aa7af2e497ec5daffa27f3d83db94448ca0
4
+ data.tar.gz: 53f63f96fe4e2e8e494f232ac624443ba8d261c0
5
5
  SHA512:
6
- metadata.gz: b1bd0b37a18f3d38d0026f0a3528711b06a07a133ce6a0f13c7f2b90c9a2e26d443e015a78aa5013b41a152ea28619d802111fd65e85846debca79113f8a11f2
7
- data.tar.gz: 2da73b7c5b2f038ebd9c904c1ef9220df09f0f5ee372d1e004d197a39a1103ed73fa019b5d453ddcfe773c42572145914696045d6b66819347beea08561e4afd
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
- @attributes_list = attributes_list.map{ |a| a.with_indifferent_access }
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
@@ -1,3 +1,3 @@
1
1
  module Dynabute
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
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.8
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-28 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord