expo 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/expo2.rb +21 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24572c0179b82dbc9aafb5bf8456a9c3668c8d54
|
4
|
+
data.tar.gz: d3de7785f3bf3ec7cb6b77e5038ede6f8a24b2b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c85a08f6e60eefd9a5ff061d6f9cdc1c2c92b436693c44c596a126c335ecc7c97f95f0737d63932badf009b8b5967d2cb456b67b89ac3ed2f47c132cad41c24
|
7
|
+
data.tar.gz: 9fdf0f2cd49cb39e3f96be3668b307b465245effeb852b008324c1857592d3f689cd02d465efd74c15b7a2017574b02fac30dedced06fc108fc006947dc7d491
|
data/lib/expo2.rb
CHANGED
@@ -94,7 +94,23 @@ class Expo2
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
class MergeExpo < Struct.new(:presenter, :sub_expo, :block)
|
98
|
+
def go(object, context, index=nil, user_expo)
|
99
|
+
assoc = self.presenter
|
100
|
+
associated = if assoc.respond_to?(:new)
|
101
|
+
assoc.new(object)
|
102
|
+
else
|
103
|
+
assoc.call(object)
|
104
|
+
end
|
105
|
+
sub = Expo2.new(self.sub_expo, &self.block)
|
106
|
+
if associated
|
107
|
+
sub.expo(associated, context)
|
108
|
+
else
|
109
|
+
{}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
98
114
|
class SubCollection < Struct.new(:associator, :key, :sub_expo, :block)
|
99
115
|
def go(object, context, index=nil)
|
100
116
|
assoc = self.associator
|
@@ -144,6 +160,10 @@ class Expo2
|
|
144
160
|
presenters << Merger.new(block)
|
145
161
|
end
|
146
162
|
|
163
|
+
def merge_expo(pres, sub_expo, &block)
|
164
|
+
presenters << MergeExpo.new(pres, sub_expo, block)
|
165
|
+
end
|
166
|
+
|
147
167
|
def sub_expo(pres, key, sub_expo, &block)
|
148
168
|
presenters << SubExpo.new(pres, key, sub_expo, block)
|
149
169
|
end
|