refr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/refr.rb +7 -9
- metadata +1 -1
data/lib/refr.rb
CHANGED
@@ -11,11 +11,13 @@
|
|
11
11
|
#++
|
12
12
|
|
13
13
|
class Reference < BasicObject
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def self.local (&block)
|
15
|
+
self.new(block.call, block.binding)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.[] (value)
|
19
|
+
self.local { :value }
|
20
|
+
end
|
19
21
|
|
20
22
|
def initialize (name, vars)
|
21
23
|
@getter = ::Kernel::eval("lambda { #{name} }", vars)
|
@@ -38,7 +40,3 @@ class Reference < BasicObject
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
|
-
|
42
|
-
def ref (&block)
|
43
|
-
Reference.new(Reference::Environment.instance_eval(&block), block.binding)
|
44
|
-
end
|