context_exposer 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 636d3dfdd4dc2b214e8f8b4b21be110979c458b2
4
- data.tar.gz: 1ee51b21d57d43d0320a7096445c6bfe1609b6a1
3
+ metadata.gz: 781e90cde85b1f59289c32f80ef319b499a6b63d
4
+ data.tar.gz: fefdaaae1ef76f21ee31ca3023f54388afa3f98a
5
5
  SHA512:
6
- metadata.gz: 093d90e0c742c7516b8dfd3caba617758a0d7ba7febcd5ea129b9552e262c8a9583cd8b4a6652ff514039557bafb96b6565baf69f81f19117846706ad801fb82
7
- data.tar.gz: 5607a5cacf2b0ba969b498dd61d4a0e4b2a6dc6debe90b000907dd6bc05c32470f648e4b7d80999210a2cbc605e61e731637325653d40d9a4f47545e44998ac1
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 :post, :posts`
279
+ `context_expose_assigned`
280
280
 
281
- In the near future there should be even better integration, so you don't have to specify the method names to expose all, just like for `context_expose_decently` ;)
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
- send "context_expose_#{name}", options
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 *names
8
- options = names.extract_options!
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 :expose_decently, :context_expose_decently
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
@@ -1,3 +1,3 @@
1
1
  module ContextExposer
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: context_exposer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Mandrup