ree 1.0.37 → 1.0.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree/link_dsl.rb +53 -15
- data/lib/ree/object_compiler.rb +1 -1
- data/lib/ree/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c82febb352bce1cb674d2b77cac4aeb8f8b1a1fcaa5fa81adae56d2e62bdb20
|
4
|
+
data.tar.gz: d23d1f28309cd3650cd90cd93bb1261011a36359c3fc6096bf8d7945fd9a8598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23819cdc3a1b4d81cbb57baa3946526138baf1662a297522f4ef8e9d4c1377bc311852d1179be445c8cfcea760660e107b97dfffa882b00a70b3b7933e3a5a9e
|
7
|
+
data.tar.gz: ce36b46fbd0fdffc547020e18eb0ee390f6a84f90150ba1bc3c3f80f59bb781d668008f852b7c47830f9a9dcd83ec59407c720024fe47c2ea8638c06b0cd987f
|
data/Gemfile.lock
CHANGED
data/lib/ree/link_dsl.rb
CHANGED
@@ -40,12 +40,16 @@ module Ree::LinkDSL
|
|
40
40
|
# @param [Nilor[Symbol]] as
|
41
41
|
# @param [Nilor[Symbol]] from
|
42
42
|
# @param [Nilor[Proc]] import
|
43
|
-
def _link_object(object_name, as: nil, from: nil, import: nil)
|
43
|
+
def _link_object(object_name, as: nil, from: nil, target: nil, import: nil)
|
44
44
|
check_arg(object_name, :object_name, Symbol)
|
45
45
|
check_arg(as, :as, Symbol) if as
|
46
46
|
check_arg(from, :from, Symbol) if from
|
47
47
|
check_arg(import, :import, Proc) if import
|
48
48
|
|
49
|
+
if target && ![:object, :class, :both].include?(target)
|
50
|
+
raise Ree::Error.new("target should be one of [:object, :class, :both]", :invalid_dsl_usage)
|
51
|
+
end
|
52
|
+
|
49
53
|
package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
|
50
54
|
link_package_name = from.nil? ? package_name : from
|
51
55
|
link_object_name = object_name
|
@@ -69,22 +73,56 @@ module Ree::LinkDSL
|
|
69
73
|
.packages_facade
|
70
74
|
.load_package_object(link_package_name, link_object_name)
|
71
75
|
|
76
|
+
target ||= obj.target
|
77
|
+
|
78
|
+
if target == :both
|
79
|
+
mount_obj(obj, link_as, true)
|
80
|
+
mount_obj(obj, link_as, false)
|
81
|
+
elsif target == :class
|
82
|
+
mount_obj(obj, link_as, true)
|
83
|
+
elsif target == :object
|
84
|
+
mount_obj(obj, link_as, false)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def mount_obj(obj, link_as, mount_self)
|
72
89
|
if obj.fn?
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
90
|
+
if obj.with_caller?
|
91
|
+
self.class_eval %Q(
|
92
|
+
#{mount_self ? "class << self" : ""}
|
93
|
+
private def #{link_as}(*args, **kwargs, &block)
|
94
|
+
#{obj.klass}.new.set_caller(self).call(*args, **kwargs, &block)
|
95
|
+
end
|
96
|
+
#{mount_self ? "end" : ""}
|
97
|
+
)
|
98
|
+
else
|
99
|
+
self.class_eval %Q(
|
100
|
+
#{mount_self ? "class << self" : ""}
|
101
|
+
private def #{link_as}(*args, **kwargs, &block)
|
102
|
+
@#{link_as} ||= #{obj.klass}.new
|
103
|
+
@#{link_as}.call(*args, **kwargs, &block)
|
104
|
+
end
|
105
|
+
#{mount_self ? "end" : ""}
|
106
|
+
)
|
107
|
+
end
|
82
108
|
else
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
109
|
+
if obj.with_caller?
|
110
|
+
self.class_eval %Q(
|
111
|
+
#{mount_self ? "class << self" : ""}
|
112
|
+
private def #{link_as}
|
113
|
+
#{obj.klass}.new.set_caller(self)
|
114
|
+
end
|
115
|
+
#{mount_self ? "end" : ""}
|
116
|
+
)
|
117
|
+
else
|
118
|
+
self.class_eval %Q(
|
119
|
+
#{mount_self ? "class << self" : ""}
|
120
|
+
private def #{link_as}
|
121
|
+
@#{link_as} ||= #{obj.klass}.new
|
122
|
+
end
|
123
|
+
#{mount_self ? "end" : ""}
|
124
|
+
)
|
125
|
+
end
|
88
126
|
end
|
89
127
|
end
|
90
128
|
|
data/lib/ree/object_compiler.rb
CHANGED
@@ -205,7 +205,7 @@ class Ree::ObjectCompiler
|
|
205
205
|
if obj.with_caller?
|
206
206
|
eval_list.push(indent + "private def #{object_link.as}")
|
207
207
|
indent = inc_indent(indent)
|
208
|
-
eval_list.push(indent + "
|
208
|
+
eval_list.push(indent + "#{obj.klass}.new.set_caller(self)")
|
209
209
|
indent = dec_indent(indent)
|
210
210
|
eval_list.push(indent + "end")
|
211
211
|
else
|
data/lib/ree/version.rb
CHANGED