jamesgolick-draper 1.1.1a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/.gitignore +16 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +22 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +150 -0
  6. data/CONTRIBUTING.md +15 -0
  7. data/Gemfile +39 -0
  8. data/Guardfile +26 -0
  9. data/LICENSE +7 -0
  10. data/README.md +417 -0
  11. data/Rakefile +69 -0
  12. data/draper.gemspec +32 -0
  13. data/lib/draper.rb +64 -0
  14. data/lib/draper/automatic_delegation.rb +56 -0
  15. data/lib/draper/collection_decorator.rb +96 -0
  16. data/lib/draper/decoratable.rb +82 -0
  17. data/lib/draper/decoratable/equality.rb +18 -0
  18. data/lib/draper/decorated_association.rb +35 -0
  19. data/lib/draper/decorates_assigned.rb +44 -0
  20. data/lib/draper/decorator.rb +248 -0
  21. data/lib/draper/delegation.rb +13 -0
  22. data/lib/draper/factory.rb +87 -0
  23. data/lib/draper/finders.rb +37 -0
  24. data/lib/draper/helper_proxy.rb +38 -0
  25. data/lib/draper/helper_support.rb +5 -0
  26. data/lib/draper/lazy_helpers.rb +15 -0
  27. data/lib/draper/railtie.rb +63 -0
  28. data/lib/draper/tasks/test.rake +22 -0
  29. data/lib/draper/test/devise_helper.rb +30 -0
  30. data/lib/draper/test/minitest_integration.rb +6 -0
  31. data/lib/draper/test/rspec_integration.rb +16 -0
  32. data/lib/draper/test_case.rb +53 -0
  33. data/lib/draper/version.rb +3 -0
  34. data/lib/draper/view_context.rb +99 -0
  35. data/lib/draper/view_context/build_strategy.rb +48 -0
  36. data/lib/draper/view_helpers.rb +37 -0
  37. data/lib/generators/decorator/decorator_generator.rb +36 -0
  38. data/lib/generators/decorator/templates/decorator.rb +19 -0
  39. data/lib/generators/mini_test/decorator_generator.rb +20 -0
  40. data/lib/generators/mini_test/templates/decorator_spec.rb +4 -0
  41. data/lib/generators/mini_test/templates/decorator_test.rb +4 -0
  42. data/lib/generators/resource_override.rb +12 -0
  43. data/lib/generators/rspec/decorator_generator.rb +9 -0
  44. data/lib/generators/rspec/templates/decorator_spec.rb +4 -0
  45. data/lib/generators/test_unit/decorator_generator.rb +9 -0
  46. data/lib/generators/test_unit/templates/decorator_test.rb +4 -0
  47. data/spec/draper/collection_decorator_spec.rb +279 -0
  48. data/spec/draper/decoratable/equality_spec.rb +10 -0
  49. data/spec/draper/decoratable_spec.rb +176 -0
  50. data/spec/draper/decorated_association_spec.rb +84 -0
  51. data/spec/draper/decorates_assigned_spec.rb +71 -0
  52. data/spec/draper/decorator_spec.rb +634 -0
  53. data/spec/draper/factory_spec.rb +238 -0
  54. data/spec/draper/finders_spec.rb +166 -0
  55. data/spec/draper/helper_proxy_spec.rb +53 -0
  56. data/spec/draper/lazy_helpers_spec.rb +21 -0
  57. data/spec/draper/view_context/build_strategy_spec.rb +116 -0
  58. data/spec/draper/view_context_spec.rb +154 -0
  59. data/spec/draper/view_helpers_spec.rb +8 -0
  60. data/spec/dummy/.rspec +2 -0
  61. data/spec/dummy/Rakefile +7 -0
  62. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  63. data/spec/dummy/app/controllers/localized_urls.rb +5 -0
  64. data/spec/dummy/app/controllers/posts_controller.rb +20 -0
  65. data/spec/dummy/app/decorators/mongoid_post_decorator.rb +2 -0
  66. data/spec/dummy/app/decorators/post_decorator.rb +56 -0
  67. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  68. data/spec/dummy/app/mailers/application_mailer.rb +3 -0
  69. data/spec/dummy/app/mailers/post_mailer.rb +19 -0
  70. data/spec/dummy/app/models/admin.rb +5 -0
  71. data/spec/dummy/app/models/mongoid_post.rb +5 -0
  72. data/spec/dummy/app/models/post.rb +3 -0
  73. data/spec/dummy/app/models/user.rb +5 -0
  74. data/spec/dummy/app/views/layouts/application.html.erb +11 -0
  75. data/spec/dummy/app/views/post_mailer/decorated_email.html.erb +1 -0
  76. data/spec/dummy/app/views/posts/_post.html.erb +34 -0
  77. data/spec/dummy/app/views/posts/show.html.erb +1 -0
  78. data/spec/dummy/bin/rails +4 -0
  79. data/spec/dummy/config.ru +4 -0
  80. data/spec/dummy/config/application.rb +71 -0
  81. data/spec/dummy/config/boot.rb +5 -0
  82. data/spec/dummy/config/database.yml +25 -0
  83. data/spec/dummy/config/environment.rb +5 -0
  84. data/spec/dummy/config/environments/development.rb +33 -0
  85. data/spec/dummy/config/environments/production.rb +57 -0
  86. data/spec/dummy/config/environments/test.rb +31 -0
  87. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/spec/dummy/config/initializers/inflections.rb +15 -0
  89. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  90. data/spec/dummy/config/initializers/secret_token.rb +8 -0
  91. data/spec/dummy/config/initializers/session_store.rb +8 -0
  92. data/spec/dummy/config/locales/en.yml +5 -0
  93. data/spec/dummy/config/mongoid.yml +80 -0
  94. data/spec/dummy/config/routes.rb +9 -0
  95. data/spec/dummy/db/migrate/20121019115657_create_posts.rb +8 -0
  96. data/spec/dummy/db/schema.rb +21 -0
  97. data/spec/dummy/db/seeds.rb +2 -0
  98. data/spec/dummy/fast_spec/post_decorator_spec.rb +38 -0
  99. data/spec/dummy/lib/tasks/test.rake +16 -0
  100. data/spec/dummy/public/404.html +26 -0
  101. data/spec/dummy/public/422.html +26 -0
  102. data/spec/dummy/public/500.html +25 -0
  103. data/spec/dummy/public/favicon.ico +0 -0
  104. data/spec/dummy/script/rails +6 -0
  105. data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +11 -0
  106. data/spec/dummy/spec/decorators/devise_spec.rb +64 -0
  107. data/spec/dummy/spec/decorators/helpers_spec.rb +21 -0
  108. data/spec/dummy/spec/decorators/post_decorator_spec.rb +58 -0
  109. data/spec/dummy/spec/decorators/spec_type_spec.rb +7 -0
  110. data/spec/dummy/spec/decorators/view_context_spec.rb +22 -0
  111. data/spec/dummy/spec/mailers/post_mailer_spec.rb +33 -0
  112. data/spec/dummy/spec/models/mongoid_post_spec.rb +8 -0
  113. data/spec/dummy/spec/models/post_spec.rb +6 -0
  114. data/spec/dummy/spec/shared_examples/decoratable.rb +24 -0
  115. data/spec/dummy/spec/spec_helper.rb +9 -0
  116. data/spec/dummy/test/decorators/minitest/devise_test.rb +64 -0
  117. data/spec/dummy/test/decorators/minitest/helpers_test.rb +21 -0
  118. data/spec/dummy/test/decorators/minitest/spec_type_test.rb +52 -0
  119. data/spec/dummy/test/decorators/minitest/view_context_test.rb +24 -0
  120. data/spec/dummy/test/decorators/test_unit/devise_test.rb +64 -0
  121. data/spec/dummy/test/decorators/test_unit/helpers_test.rb +21 -0
  122. data/spec/dummy/test/decorators/test_unit/view_context_test.rb +24 -0
  123. data/spec/dummy/test/minitest_helper.rb +4 -0
  124. data/spec/dummy/test/test_helper.rb +3 -0
  125. data/spec/generators/decorator/decorator_generator_spec.rb +130 -0
  126. data/spec/integration/integration_spec.rb +58 -0
  127. data/spec/performance/active_record.rb +4 -0
  128. data/spec/performance/benchmark.rb +55 -0
  129. data/spec/performance/decorators.rb +45 -0
  130. data/spec/performance/models.rb +20 -0
  131. data/spec/spec_helper.rb +37 -0
  132. data/spec/support/dummy_app.rb +85 -0
  133. data/spec/support/matchers/have_text.rb +50 -0
  134. data/spec/support/shared_examples/decoratable_equality.rb +40 -0
  135. data/spec/support/shared_examples/view_helpers.rb +39 -0
  136. metadata +451 -0
@@ -0,0 +1,44 @@
1
+ module Draper
2
+ module DecoratesAssigned
3
+ # @overload decorates_assigned(*variables, options = {})
4
+ # Defines a helper method to access decorated instance variables.
5
+ #
6
+ # @example
7
+ # # app/controllers/articles_controller.rb
8
+ # class ArticlesController < ApplicationController
9
+ # decorates_assigned :article
10
+ #
11
+ # def show
12
+ # @article = Article.find(params[:id])
13
+ # end
14
+ # end
15
+ #
16
+ # # app/views/articles/show.html.erb
17
+ # <%= article.decorated_title %>
18
+ #
19
+ # @param [Symbols*] variables
20
+ # names of the instance variables to decorate (without the `@`).
21
+ # @param [Hash] options
22
+ # @option options [Decorator, CollectionDecorator] :with (nil)
23
+ # decorator class to use. If nil, it is inferred from the instance
24
+ # variable.
25
+ # @option options [Hash, #call] :context
26
+ # extra data to be stored in the decorator. If a Proc is given, it will
27
+ # be passed the controller and should return a new context hash.
28
+ def decorates_assigned(*variables)
29
+ factory = Draper::Factory.new(variables.extract_options!)
30
+
31
+ variables.each do |variable|
32
+ undecorated = "@#{variable}"
33
+ decorated = "@decorated_#{variable}"
34
+
35
+ define_method variable do
36
+ return instance_variable_get(decorated) if instance_variable_defined?(decorated)
37
+ instance_variable_set decorated, factory.decorate(instance_variable_get(undecorated), context_args: self)
38
+ end
39
+
40
+ helper_method variable
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,248 @@
1
+ module Draper
2
+ class Decorator
3
+ include Draper::ViewHelpers
4
+ extend Draper::Delegation
5
+
6
+ include ActiveModel::Serialization
7
+ include ActiveModel::Serializers::JSON
8
+ include ActiveModel::Serializers::Xml
9
+
10
+ # @return the object being decorated.
11
+ attr_reader :source
12
+ alias_method :model, :source
13
+ alias_method :to_source, :source
14
+
15
+ # @return [Hash] extra data to be used in user-defined methods.
16
+ attr_accessor :context
17
+
18
+ # Wraps an object in a new instance of the decorator.
19
+ #
20
+ # Decorators may be applied to other decorators. However, applying a
21
+ # decorator to an instance of itself will create a decorator with the same
22
+ # source as the original, rather than redecorating the other instance.
23
+ #
24
+ # @param [Object] source
25
+ # object to decorate.
26
+ # @option options [Hash] :context ({})
27
+ # extra data to be stored in the decorator and used in user-defined
28
+ # methods.
29
+ def initialize(source, options = {})
30
+ options.assert_valid_keys(:context)
31
+ @source = source
32
+ @context = options.fetch(:context, {})
33
+ handle_multiple_decoration(options) if source.instance_of?(self.class)
34
+ end
35
+
36
+ class << self
37
+ alias_method :decorate, :new
38
+ end
39
+
40
+ # Automatically delegates instance methods to the source object. Class
41
+ # methods will be delegated to the {source_class}, if it is set.
42
+ #
43
+ # @return [void]
44
+ def self.delegate_all
45
+ include Draper::AutomaticDelegation
46
+ end
47
+
48
+ # Sets the source class corresponding to the decorator class.
49
+ #
50
+ # @note This is only necessary if you wish to proxy class methods to the
51
+ # source (including when using {decorates_finders}), and the source class
52
+ # cannot be inferred from the decorator class (e.g. `ProductDecorator`
53
+ # maps to `Product`).
54
+ # @param [String, Symbol, Class] source_class
55
+ # source class (or class name) that corresponds to this decorator.
56
+ # @return [void]
57
+ def self.decorates(source_class)
58
+ @source_class = source_class.to_s.camelize.constantize
59
+ end
60
+
61
+ # Returns the source class corresponding to the decorator class, as set by
62
+ # {decorates}, or as inferred from the decorator class name (e.g.
63
+ # `ProductDecorator` maps to `Product`).
64
+ #
65
+ # @return [Class] the source class that corresponds to this decorator.
66
+ def self.source_class
67
+ @source_class ||= inferred_source_class
68
+ end
69
+
70
+ # Checks whether this decorator class has a corresponding {source_class}.
71
+ def self.source_class?
72
+ source_class
73
+ rescue Draper::UninferrableSourceError
74
+ false
75
+ end
76
+
77
+ # Automatically decorates ActiveRecord finder methods, so that you can use
78
+ # `ProductDecorator.find(id)` instead of
79
+ # `ProductDecorator.decorate(Product.find(id))`.
80
+ #
81
+ # Finder methods are applied to the {source_class}.
82
+ #
83
+ # @return [void]
84
+ def self.decorates_finders
85
+ extend Draper::Finders
86
+ end
87
+
88
+ # Automatically decorate an association.
89
+ #
90
+ # @param [Symbol] association
91
+ # name of the association to decorate (e.g. `:products`).
92
+ # @option options [Class] :with
93
+ # the decorator to apply to the association.
94
+ # @option options [Symbol] :scope
95
+ # a scope to apply when fetching the association.
96
+ # @option options [Hash, #call] :context
97
+ # extra data to be stored in the associated decorator. If omitted, the
98
+ # associated decorator's context will be the same as the parent
99
+ # decorator's. If a Proc is given, it will be called with the parent's
100
+ # context and should return a new context hash for the association.
101
+ # @return [void]
102
+ def self.decorates_association(association, options = {})
103
+ options.assert_valid_keys(:with, :scope, :context)
104
+ define_method(association) do
105
+ decorated_associations[association] ||= Draper::DecoratedAssociation.new(self, association, options)
106
+ decorated_associations[association].call
107
+ end
108
+ end
109
+
110
+ # @overload decorates_associations(*associations, options = {})
111
+ # Automatically decorate multiple associations.
112
+ # @param [Symbols*] associations
113
+ # names of the associations to decorate.
114
+ # @param [Hash] options
115
+ # see {decorates_association}.
116
+ # @return [void]
117
+ def self.decorates_associations(*associations)
118
+ options = associations.extract_options!
119
+ associations.each do |association|
120
+ decorates_association(association, options)
121
+ end
122
+ end
123
+
124
+ # Decorates a collection of objects. The class of the collection decorator
125
+ # is inferred from the decorator class if possible (e.g. `ProductDecorator`
126
+ # maps to `ProductsDecorator`), but otherwise defaults to
127
+ # {Draper::CollectionDecorator}.
128
+ #
129
+ # @param [Object] source
130
+ # collection to decorate.
131
+ # @option options [Class, nil] :with (self)
132
+ # the decorator class used to decorate each item. When `nil`, it is
133
+ # inferred from each item.
134
+ # @option options [Hash] :context
135
+ # extra data to be stored in the collection decorator.
136
+ def self.decorate_collection(source, options = {})
137
+ options.assert_valid_keys(:with, :context)
138
+ collection_decorator_class.new(source, options.reverse_merge(with: self))
139
+ end
140
+
141
+ # @return [Array<Class>] the list of decorators that have been applied to
142
+ # the object.
143
+ def applied_decorators
144
+ chain = source.respond_to?(:applied_decorators) ? source.applied_decorators : []
145
+ chain << self.class
146
+ end
147
+
148
+ # Checks if a given decorator has been applied to the object.
149
+ #
150
+ # @param [Class] decorator_class
151
+ def decorated_with?(decorator_class)
152
+ applied_decorators.include?(decorator_class)
153
+ end
154
+
155
+ # Checks if this object is decorated.
156
+ #
157
+ # @return [true]
158
+ def decorated?
159
+ true
160
+ end
161
+
162
+ # Compares the source with a possibly-decorated object.
163
+ #
164
+ # @return [Boolean]
165
+ def ==(other)
166
+ Draper::Decoratable::Equality.test(source, other)
167
+ end
168
+
169
+ # Checks if `self.kind_of?(klass)` or `source.kind_of?(klass)`
170
+ #
171
+ # @param [Class] klass
172
+ def kind_of?(klass)
173
+ super || source.kind_of?(klass)
174
+ end
175
+ alias_method :is_a?, :kind_of?
176
+
177
+ # Checks if `self.instance_of?(klass)` or `source.instance_of?(klass)`
178
+ #
179
+ # @param [Class] klass
180
+ def instance_of?(klass)
181
+ super || source.instance_of?(klass)
182
+ end
183
+
184
+ # In case source is nil
185
+ delegate :present?
186
+
187
+ # ActiveModel compatibility
188
+ # @private
189
+ def to_model
190
+ self
191
+ end
192
+
193
+ # @return [Hash] the source's attributes, sliced to only include those
194
+ # implemented by the decorator.
195
+ def attributes
196
+ source.attributes.select {|attribute, _| respond_to?(attribute) }
197
+ end
198
+
199
+ # ActiveModel compatibility
200
+ delegate :to_param, :to_partial_path
201
+
202
+ # ActiveModel compatibility
203
+ singleton_class.delegate :model_name, to: :source_class
204
+
205
+ # @return [Class] the class created by {decorate_collection}.
206
+ def self.collection_decorator_class
207
+ name = collection_decorator_name
208
+ name.constantize
209
+ rescue NameError => error
210
+ raise if name && !error.missing_name?(name)
211
+ Draper::CollectionDecorator
212
+ end
213
+
214
+ private
215
+
216
+ def self.source_name
217
+ raise NameError if name.nil? || name.demodulize !~ /.+Decorator$/
218
+ name.chomp("Decorator")
219
+ end
220
+
221
+ def self.inferred_source_class
222
+ name = source_name
223
+ name.constantize
224
+ rescue NameError => error
225
+ raise if name && !error.missing_name?(name)
226
+ raise Draper::UninferrableSourceError.new(self)
227
+ end
228
+
229
+ def self.collection_decorator_name
230
+ plural = source_name.pluralize
231
+ raise NameError if plural == source_name
232
+ "#{plural}Decorator"
233
+ end
234
+
235
+ def handle_multiple_decoration(options)
236
+ if source.applied_decorators.last == self.class
237
+ @context = source.context unless options.has_key?(:context)
238
+ @source = source.source
239
+ else
240
+ warn "Reapplying #{self.class} decorator to target that is already decorated with it. Call stack:\n#{caller(1).join("\n")}"
241
+ end
242
+ end
243
+
244
+ def decorated_associations
245
+ @decorated_associations ||= {}
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,13 @@
1
+ module Draper
2
+ module Delegation
3
+ # @overload delegate(*methods, options = {})
4
+ # Overrides {http://api.rubyonrails.org/classes/Module.html#method-i-delegate Module.delegate}
5
+ # to make `:source` the default delegation target.
6
+ #
7
+ # @return [void]
8
+ def delegate(*methods)
9
+ options = methods.extract_options!
10
+ super *methods, options.reverse_merge(to: :source)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,87 @@
1
+ module Draper
2
+ class Factory
3
+ # Creates a decorator factory.
4
+ #
5
+ # @option options [Decorator, CollectionDecorator] :with (nil)
6
+ # decorator class to use. If nil, it is inferred from the object
7
+ # passed to {#decorate}.
8
+ # @option options [Hash, #call] context
9
+ # extra data to be stored in created decorators. If a proc is given, it
10
+ # will be called each time {#decorate} is called and its return value
11
+ # will be used as the context.
12
+ def initialize(options = {})
13
+ options.assert_valid_keys(:with, :context)
14
+ @decorator_class = options.delete(:with)
15
+ @default_options = options
16
+ end
17
+
18
+ # Decorates an object, inferring whether to create a singular or collection
19
+ # decorator from the type of object passed.
20
+ #
21
+ # @param [Object] source
22
+ # object to decorate.
23
+ # @option options [Hash] context
24
+ # extra data to be stored in the decorator. Overrides any context passed
25
+ # to the constructor.
26
+ # @option options [Object, Array] context_args (nil)
27
+ # argument(s) to be passed to the context proc.
28
+ # @return [Decorator, CollectionDecorator] the decorated object.
29
+ def decorate(source, options = {})
30
+ return nil if source.nil?
31
+ Worker.new(decorator_class, source).call(options.reverse_merge(default_options))
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :decorator_class, :default_options
37
+
38
+ # @private
39
+ class Worker
40
+ def initialize(decorator_class, source)
41
+ @decorator_class = decorator_class
42
+ @source = source
43
+ end
44
+
45
+ def call(options)
46
+ update_context options
47
+ decorator.call(source, options)
48
+ end
49
+
50
+ def decorator
51
+ return decorator_method(decorator_class) if decorator_class
52
+ return source_decorator if decoratable?
53
+ return decorator_method(Draper::CollectionDecorator) if collection?
54
+ raise Draper::UninferrableDecoratorError.new(source.class)
55
+ end
56
+
57
+ private
58
+
59
+ attr_reader :decorator_class, :source
60
+
61
+ def source_decorator
62
+ ->(source, options) { source.decorate(options) }
63
+ end
64
+
65
+ def decorator_method(klass)
66
+ if collection? && klass.respond_to?(:decorate_collection)
67
+ klass.method(:decorate_collection)
68
+ else
69
+ klass.method(:decorate)
70
+ end
71
+ end
72
+
73
+ def collection?
74
+ source.respond_to?(:first)
75
+ end
76
+
77
+ def decoratable?
78
+ source.respond_to?(:decorate)
79
+ end
80
+
81
+ def update_context(options)
82
+ args = options.delete(:context_args)
83
+ options[:context] = options[:context].call(*Array.wrap(args)) if options[:context].respond_to?(:call)
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,37 @@
1
+ module Draper
2
+ # Provides automatically-decorated finder methods for your decorators. You
3
+ # do not have to extend this module directly; it is extended by
4
+ # {Decorator.decorates_finders}.
5
+ module Finders
6
+
7
+ def find(id, options = {})
8
+ decorate(source_class.find(id), options)
9
+ end
10
+
11
+ def all(options = {})
12
+ decorate_collection(source_class.all, options)
13
+ end
14
+
15
+ def first(options = {})
16
+ decorate(source_class.first, options)
17
+ end
18
+
19
+ def last(options = {})
20
+ decorate(source_class.last, options)
21
+ end
22
+
23
+ # Decorates dynamic finder methods (`find_all_by_` and friends).
24
+ def method_missing(method, *args, &block)
25
+ return super unless method =~ /^find_(all_|last_|or_(initialize_|create_))?by_/
26
+
27
+ result = source_class.send(method, *args, &block)
28
+ options = args.extract_options!
29
+
30
+ if method =~ /^find_all/
31
+ decorate_collection(result, options)
32
+ else
33
+ decorate(result, options)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ module Draper
2
+ # Provides access to helper methods - both Rails built-in helpers, and those
3
+ # defined in your application.
4
+ class HelperProxy
5
+
6
+ # @overload initialize(view_context)
7
+ def initialize(view_context = nil)
8
+ view_context ||= current_view_context # backwards compatibility
9
+
10
+ @view_context = view_context
11
+ end
12
+
13
+ # Sends helper methods to the view context.
14
+ def method_missing(method, *args, &block)
15
+ self.class.define_proxy method
16
+ send(method, *args, &block)
17
+ end
18
+
19
+ delegate :capture, to: :view_context
20
+
21
+ protected
22
+
23
+ attr_reader :view_context
24
+
25
+ private
26
+
27
+ def self.define_proxy(name)
28
+ define_method name do |*args, &block|
29
+ view_context.send(name, *args, &block)
30
+ end
31
+ end
32
+
33
+ def current_view_context
34
+ ActiveSupport::Deprecation.warn("wrong number of arguments (0 for 1) passed to Draper::HelperProxy.new", caller[1..-1])
35
+ Draper::ViewContext.current.view_context
36
+ end
37
+ end
38
+ end