context_exposer 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/context_exposer/base_controller.rb +3 -1
- data/lib/context_exposer/integrations/with_draper.rb +15 -6
- data/lib/context_exposer/version.rb +1 -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: 781e90cde85b1f59289c32f80ef319b499a6b63d
|
4
|
+
data.tar.gz: fefdaaae1ef76f21ee31ca3023f54388afa3f98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da47a81eadbd083cd217614c8b292e85187dcb5c9da2b89aa3eca85247cde1825d075f711945f88f4d31e6c6398eb7a9e57360a75f25f46394ee0412ad8816d2
|
7
|
+
data.tar.gz: 702b3dd9caa81dd62ef0d080a63478b893c8a2dcbcce8f02db8c9e396a7f69155bc6294686c940ee3ef648c8113f7718f6eda13318262738064af349d5ca7960
|
data/README.md
CHANGED
@@ -274,13 +274,11 @@ decorates_assigned :article, with: FancyArticleDecorator
|
|
274
274
|
decorates_assigned :articles, with: PaginatingCollectionDecorator
|
275
275
|
```
|
276
276
|
|
277
|
-
Since this functionality is very similar to fx `decent_exposure`, it can be used with `ctx` in a similar way. Simply use the `context_expose_assigned` macro.
|
277
|
+
Since this functionality is very similar to fx `decent_exposure`, it can be used with `ctx` in a similar way. Simply use the `context_expose_assigned` like the `context_expose_decently` macro.
|
278
278
|
|
279
|
-
`context_expose_assigned
|
279
|
+
`context_expose_assigned`
|
280
280
|
|
281
|
-
|
282
|
-
|
283
|
-
See [commit comment](https://github.com/haines/draper/commit/afa97bb401666f47ef380d7c9e8e94a8b472597d#commitcomment-2844631)
|
281
|
+
`context_expose_assigned only: %w{post posts}
|
284
282
|
|
285
283
|
## Decorates before rendering
|
286
284
|
|
@@ -69,7 +69,9 @@ module ContextExposer::BaseController
|
|
69
69
|
alias_method :integrates_with, :integrate_with
|
70
70
|
|
71
71
|
def context_expose name, options = {}
|
72
|
-
|
72
|
+
meth_name = "context_expose_#{name}"
|
73
|
+
raise ArgumentError, "No such method #{meth_name}" unless respond_to? meth_name
|
74
|
+
send meth_name, options
|
73
75
|
end
|
74
76
|
|
75
77
|
def _exposure_storage
|
@@ -3,12 +3,15 @@ module ContextExposer::Integrations
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
+
def decorates_assigned(*variables)
|
7
|
+
super
|
8
|
+
variables.extract_options!
|
9
|
+
@decorates_assigned_list = variables
|
10
|
+
end
|
11
|
+
|
6
12
|
# expose all exposures exposed by decent_exposure to context
|
7
|
-
def context_expose_assigned
|
8
|
-
|
9
|
-
expose_keys = names
|
10
|
-
expose_keys = _assigned.keys if expose_keys.empty? && respond_to? :_assigned
|
11
|
-
return if expose_keys.blank?
|
13
|
+
def context_expose_assigned options = {}
|
14
|
+
expose_keys = _decorates_assigned_list
|
12
15
|
|
13
16
|
_exposure_filter(expose_keys, options).each do |exposure|
|
14
17
|
exposed exposure do
|
@@ -16,7 +19,13 @@ module ContextExposer::Integrations
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
alias_method :
|
22
|
+
alias_method :expose_assigned, :context_expose_assigned
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def _decorates_assigned_list
|
27
|
+
@decorates_assigned_list
|
28
|
+
end
|
20
29
|
end
|
21
30
|
end
|
22
31
|
end
|