Class: Frosting::BasePresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Frosting::BasePresenter
show all
- Includes:
- Presentation
- Defined in:
- lib/frosting/base_presenter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#present, #present_collection
Constructor Details
#initialize(resource, context = nil) ⇒ BasePresenter
19
20
21
22
23
|
# File 'lib/frosting/base_presenter.rb', line 19
def initialize(resource, context = nil)
@context = context
@wrapped = resource
super(@wrapped)
end
|
Class Method Details
.presents_super(*arguments) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/frosting/base_presenter.rb', line 8
def self.presents_super(*arguments)
options = arguments.last.is_a?(Hash) ? arguments.pop : {}
present_method = options.delete(:collection) ? :present_collection : :present
arguments.each do |method|
define_method(method) do
send(present_method, super(), options.merge(context: @context))
end
end
end
|