open_dsl 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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?(value)
27
- assign_constant_to_explicit_attribute(name, value, &blk)
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, value)
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, value)
63
+ def assign_attribute(name, *values)
65
64
  if @stack.bottom.kind_of?(Array)
66
- @stack.bottom << value
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 && value.nil?
68
+ if @toplevel_object_already_exists && values.size == 0
70
69
  @stack.bottom.send("#{name}=", true)
71
70
  else
72
- @stack.bottom.send("#{name}=", value)
71
+ @stack.bottom.send("#{name}=", *values)
73
72
  end
74
73
  end
75
74
  end
data/lib/open_dsl.rb CHANGED
@@ -8,7 +8,7 @@ require 'open_dsl/context'
8
8
  require 'open_dsl/eval_stack'
9
9
 
10
10
  module OpenDsl
11
- VERSION = '0.3.1'
11
+ VERSION = '0.3.2'
12
12
  end
13
13
 
14
14
  def open_dsl(&blk)
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: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ian Leitch