open_dsl 0.3.1 → 0.3.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.
- data/lib/open_dsl/context.rb +7 -8
- data/lib/open_dsl.rb +1 -1
- metadata +3 -3
data/lib/open_dsl/context.rb
CHANGED
@@ -19,12 +19,11 @@ module OpenDsl
|
|
19
19
|
def method_missing(name, *args, &blk)
|
20
20
|
# TODO: detect an internal error?
|
21
21
|
|
22
|
-
value = args.first
|
23
22
|
if constant_or_constant_name?(name)
|
24
23
|
assign_constant(name, &blk)
|
25
24
|
elsif blk
|
26
|
-
if constant_or_constant_name?(
|
27
|
-
assign_constant_to_explicit_attribute(name,
|
25
|
+
if constant_or_constant_name?(args.first)
|
26
|
+
assign_constant_to_explicit_attribute(name, args.first, &blk)
|
28
27
|
else
|
29
28
|
if plural?(name)
|
30
29
|
assign_collection(name, &blk)
|
@@ -33,7 +32,7 @@ module OpenDsl
|
|
33
32
|
end
|
34
33
|
end
|
35
34
|
else
|
36
|
-
assign_attribute(name,
|
35
|
+
assign_attribute(name, *args)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -61,15 +60,15 @@ module OpenDsl
|
|
61
60
|
@stack.eval(array, &blk)
|
62
61
|
end
|
63
62
|
|
64
|
-
def assign_attribute(name,
|
63
|
+
def assign_attribute(name, *values)
|
65
64
|
if @stack.bottom.kind_of?(Array)
|
66
|
-
@stack.bottom <<
|
65
|
+
@stack.bottom << (values.size == 1 ? values.first : values)
|
67
66
|
else
|
68
67
|
define_getter_and_setter_if_needed(name)
|
69
|
-
if @toplevel_object_already_exists &&
|
68
|
+
if @toplevel_object_already_exists && values.size == 0
|
70
69
|
@stack.bottom.send("#{name}=", true)
|
71
70
|
else
|
72
|
-
@stack.bottom.send("#{name}=",
|
71
|
+
@stack.bottom.send("#{name}=", *values)
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
data/lib/open_dsl.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ian Leitch
|