dsl_accessor 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ module DslAccessor
11
11
  if !dsl_accessor_key?(key)
12
12
  # load default value
13
13
  default = dsl_accessor_get("#{key}_default")
14
- value = default ? default.call : nil
14
+ value = default ? instance_eval(&default) : nil
15
15
  dsl_accessor_writer(key, value)
16
16
  end
17
17
  dsl_accessor_get(key)
@@ -1,4 +1,4 @@
1
1
  module DslAccessor
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
4
4
 
@@ -36,4 +36,13 @@ describe DslAccessor do
36
36
  k1.dsl_accessor :foo, :default=>proc{1}
37
37
  k1.foo.should == 1
38
38
  end
39
+
40
+ it "should call it in his own context when proc given" do
41
+ # ensure that no 'name' in this context
42
+ lambda { name }.should raise_error(NameError)
43
+
44
+ k1 = Class.new
45
+ k1.dsl_accessor :my_name, :default=>proc{self.name}
46
+ lambda { k1.my_name }.should_not raise_error
47
+ end
39
48
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_accessor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - maiha