aduki 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aduki.rb +2 -0
- data/lib/aduki/version.rb +1 -1
- data/spec/custom_builder_spec.rb +18 -0
- data/spec/spec_helper.rb +16 -1
- metadata +4 -2
data/lib/aduki.rb
CHANGED
data/lib/aduki/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "aduki"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Aduki::Initializer do
|
5
|
+
|
6
|
+
it "should assign a value using a custom finder" do
|
7
|
+
props = {
|
8
|
+
"name" => "Anna Livia",
|
9
|
+
"city" => "dublin"
|
10
|
+
}
|
11
|
+
|
12
|
+
contraption = MachineBuilder.new props
|
13
|
+
|
14
|
+
expect(contraption.name).to eq "Anna Livia"
|
15
|
+
expect(contraption.city).to eq CITIES["dublin"]
|
16
|
+
expect(contraption.city.name).to eq "Dublin"
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,20 @@ RSpec.configure do |config|
|
|
5
5
|
config.order = 'random'
|
6
6
|
end
|
7
7
|
|
8
|
+
|
9
|
+
CITIES = { }
|
10
|
+
|
11
|
+
class City < Struct.new(:name)
|
12
|
+
def self.aduki_find value
|
13
|
+
CITIES[value]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
CITIES["paris"] = City.new "Paris"
|
18
|
+
CITIES["madrid"] = City.new "Madrid"
|
19
|
+
CITIES["stockholm"] = City.new "Stockholm"
|
20
|
+
CITIES["dublin"] = City.new "Dublin"
|
21
|
+
|
8
22
|
class Contraption
|
9
23
|
include Aduki::Initializer
|
10
24
|
attr_accessor :x, :y, :planned, :updated
|
@@ -19,7 +33,8 @@ end
|
|
19
33
|
|
20
34
|
class MachineBuilder
|
21
35
|
include Aduki::Initializer
|
22
|
-
attr_accessor :name, :email, :phone, :office
|
36
|
+
attr_accessor :name, :email, :phone, :office, :city
|
37
|
+
aduki :city => City
|
23
38
|
end
|
24
39
|
|
25
40
|
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.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/aduki.rb
|
61
61
|
- lib/aduki/version.rb
|
62
62
|
- spec/array_attribute_spec.rb
|
63
|
+
- spec/custom_builder_spec.rb
|
63
64
|
- spec/initializer_spec.rb
|
64
65
|
- spec/model.rb
|
65
66
|
- spec/nil_initializer_spec.rb
|
@@ -94,6 +95,7 @@ specification_version: 3
|
|
94
95
|
summary: set object attributes recursively from an attributes hash
|
95
96
|
test_files:
|
96
97
|
- spec/array_attribute_spec.rb
|
98
|
+
- spec/custom_builder_spec.rb
|
97
99
|
- spec/initializer_spec.rb
|
98
100
|
- spec/model.rb
|
99
101
|
- spec/nil_initializer_spec.rb
|