aduki 0.2.1 → 0.2.2

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: 8040242d5e9e51d7233a9b242be7fa4b36dae799
4
- data.tar.gz: f0b11e535855d72505939e1a838eba627eef6789
3
+ metadata.gz: 0681494a2a4133047eb70952bec208ddf1e737e4
4
+ data.tar.gz: 76eef24aa7d051a67faae78e7651c879655272fc
5
5
  SHA512:
6
- metadata.gz: 03106a7359d34c1bcc584e626ad33b258cd9f348b57ed3b37d499cccb6d956b99878df9f15a0eb965f75483be692be8104552f3333faf813568fd04ff5a6aee5
7
- data.tar.gz: 6c7c6c2301e8ee49599093b31fbb32161478a13eb8a7417218ff91831d50b2bc4687a136fc03aef70e94a56c9fa99c272006dd1e42cb9d56531fca77f80d1600
6
+ metadata.gz: bb88d8aacc43c875b8f62ddc2cad6dae344adec9c7586afaa93805690d7d13dd3a5508bc8244ecf1a4476a92ccaf0aa16651fb4ef6c1de91f522cfe292f7442f
7
+ data.tar.gz: 8f8515478e5beda599113476a6d6d9e51cfd0ff3e6702d1a24db916291dbfab5e36b8ad3076d788190c99c4b76ba9cb83a233a966395357f551cfa1d84da55cd
@@ -89,13 +89,9 @@ module Aduki
89
89
  def self.apply_array_attribute klass, object, getter, value
90
90
  setter_method = "#{getter}=".to_sym
91
91
  return unless object.respond_to? setter_method
92
-
93
- array = object.send getter
94
- if array == nil
95
- array = []
96
- object.send(setter_method, array)
97
- end
92
+ array = object.send(getter) || []
98
93
  array << to_value(klass, getter, value)
94
+ object.send(setter_method, array)
99
95
  end
100
96
 
101
97
  def self.apply_new_single_attribute klass, object, setter, value
@@ -177,7 +173,7 @@ module Aduki
177
173
  end
178
174
 
179
175
  def attr_many_finder finder, id, name, options={ }
180
- class_eval Aduki::AttrFinder.one2many_attr_finder_text(finder, id, name, options={ })
176
+ class_eval Aduki::AttrFinder.one2many_attr_finder_text(finder, id, name, options)
181
177
  end
182
178
  end
183
179
 
@@ -1,3 +1,3 @@
1
1
  module Aduki
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -9,6 +9,9 @@ describe Aduki::AttrFinder do
9
9
  "gift_names[0]" => "dinner",
10
10
  "gift_names[1]" => "whiskey",
11
11
  "gift_names[2]" => "cigars",
12
+ "spk_ohms[0]" => 101,
13
+ "spk_ohms[1]" => 104,
14
+ "spk_ohms[2]" => 98,
12
15
  }
13
16
 
14
17
  politician = Politician.new props
@@ -17,6 +20,10 @@ describe Aduki::AttrFinder do
17
20
  expect(politician.city).to eq City::CITIES["dublin"]
18
21
  expect(politician.city.name).to eq "dublin"
19
22
  expect(politician.gifts).to eq [Gift.lookup("dinner"), Gift.lookup("whiskey"), Gift.lookup("cigars")]
23
+
24
+ expect(politician.spks) .to be_a Array
25
+ expect(politician.spks.map(&:class).uniq).to eq [Speaker]
26
+ expect(politician.spks.map(&:ohms)) .to eq [101, 104, 98]
20
27
  end
21
28
 
22
29
  it "does not override a value with unknown identifier" do
@@ -45,6 +45,7 @@ class Politician
45
45
  attr_accessor :name
46
46
  attr_finder :aduki_find, :name, :city
47
47
  attr_many_finder :lookup, :name, :gifts
48
+ attr_many_finder :make?, :ohms, :spks, :class_name => "Speaker"
48
49
  end
49
50
 
50
51
  class Contraption
@@ -73,6 +74,10 @@ class Speaker
73
74
  aduki_initialize :dates, Array, Date
74
75
  aduki_initialize :dimensions, Array, nil
75
76
  aduki_initialize :threads, Array, nil
77
+
78
+ def self.make? ohms
79
+ ohms.is_a?(Integer) ? Speaker.new(ohms: ohms) : ohms.map { |o| make? o }
80
+ end
76
81
  end
77
82
 
78
83
  class Gadget
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aduki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conan Dalton