Skip to content

Commit b36ef05

Browse files
committed
WashOut can now accept types at first level of definition (fixes #95)
1 parent ec330e6 commit b36ef05

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GIT
99
PATH
1010
remote: .
1111
specs:
12-
wash_out (0.7.1)
12+
wash_out (0.8.0)
1313
nori (>= 2.0.0)
1414

1515
GEM

lib/wash_out/param.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ def self.parse_def(definition)
133133
raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == []
134134
return [] if definition == nil
135135

136-
if [Array, Symbol, Class].include?(definition.class)
136+
if definition.is_a?(Class) && definition.ancestors.include?(WashOut::Type)
137+
definition = definition.wash_out_param_map
138+
end
139+
140+
if [Array, Symbol].include?(definition.class)
137141
definition = { :value => definition }
138142
end
139143

lib/wash_out/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module WashOut
2-
VERSION = "0.7.1"
2+
VERSION = "0.8.0"
33
end

spec/lib/wash_out/param_spec.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ class Abraka2 < WashOut::Type
1919
map = WashOut::Param.parse_def Abraka2
2020

2121
map.should be_a_kind_of(Array)
22-
map[0].name.should == 'value'
23-
map[0].map[0].name.should == 'foo'
24-
map[0].map[0].map[0].name.should == 'test'
22+
map[0].name.should == 'foo'
23+
map[0].map[0].name.should == 'test'
2524
end
2625

2726
it "respects camelization setting" do
@@ -30,9 +29,8 @@ class Abraka2 < WashOut::Type
3029
map = WashOut::Param.parse_def Abraka2
3130

3231
map.should be_a_kind_of(Array)
33-
map[0].name.should == 'Value'
34-
map[0].map[0].name.should == 'Foo'
35-
map[0].map[0].map[0].name.should == 'Test'
32+
map[0].name.should == 'Foo'
33+
map[0].map[0].name.should == 'Test'
3634
end
3735
end
3836

0 commit comments

Comments
 (0)