expo 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/expo.rb +26 -27
- metadata +1 -1
data/lib/expo.rb
CHANGED
@@ -61,7 +61,20 @@ class Expo
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
def aside(*messages)
|
65
|
+
array, hash = parse_arguments(messages)
|
66
|
+
@context.merge!(hasherize(array) {|msg| @preso.send(msg) })
|
67
|
+
hash.each do |k,v|
|
68
|
+
@context[v] = @preso.send(k)
|
69
|
+
end
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def expose(*messages)
|
74
|
+
array, hash = parse_arguments(messages)
|
75
|
+
@message_map.merge!(hasherize(array).merge(hash))
|
76
|
+
nil
|
77
|
+
end
|
65
78
|
|
66
79
|
def sub_expo(key, object, sub_expo_passed)
|
67
80
|
@inner_calls << {
|
@@ -81,6 +94,8 @@ class Expo
|
|
81
94
|
nil
|
82
95
|
end
|
83
96
|
|
97
|
+
private
|
98
|
+
|
84
99
|
def set_id(id)
|
85
100
|
@id = id
|
86
101
|
self
|
@@ -121,37 +136,21 @@ class Expo
|
|
121
136
|
nil
|
122
137
|
end
|
123
138
|
|
124
|
-
def
|
125
|
-
|
126
|
-
|
127
|
-
if last.is_a?(Hash)
|
128
|
-
last.each do |k,v|
|
129
|
-
@context[v] = receiver.send(k)
|
130
|
-
end
|
131
|
-
elsif last
|
132
|
-
@context[last] = receiver.send(last)
|
133
|
-
end
|
134
|
-
if messages.any?
|
135
|
-
@context.merge!(hasherize(messages) {|msg| receiver.send(msg) })
|
136
|
-
end
|
137
|
-
nil
|
139
|
+
def hasherize(array, &block)
|
140
|
+
block ||= ->(e) { e }
|
141
|
+
Hash[*array.map{|e| [e, block.call(e)] }.flatten]
|
138
142
|
end
|
139
143
|
|
140
|
-
def
|
141
|
-
last =
|
144
|
+
def parse_arguments(args)
|
145
|
+
last = args.pop
|
146
|
+
array = args
|
147
|
+
hash = {}
|
142
148
|
if last.is_a?(Hash)
|
143
|
-
|
149
|
+
hash = last
|
144
150
|
elsif last
|
145
|
-
|
151
|
+
array << last
|
146
152
|
end
|
147
|
-
|
148
|
-
@message_map.merge!(hasherize(messages) {|msg| msg })
|
149
|
-
end
|
150
|
-
nil
|
151
|
-
end
|
152
|
-
|
153
|
-
def hasherize(array, &block)
|
154
|
-
Hash[*array.map{|e| [e, block.call(e)] }.flatten]
|
153
|
+
[array, hash]
|
155
154
|
end
|
156
155
|
|
157
156
|
class Proxy
|