Module: Keynote
- Defined in:
- lib/keynote/core.rb,
lib/keynote/cache.rb,
lib/keynote/helper.rb,
lib/keynote/inline.rb,
lib/keynote/rumble.rb,
lib/keynote/railtie.rb,
lib/keynote/version.rb,
lib/keynote/presenter.rb,
lib/keynote/controller.rb,
lib/keynote/testing/rspec.rb,
lib/keynote/testing/minitest.rb,
lib/keynote/testing/test_unit.rb,
lib/keynote/testing/test_present_method.rb
Overview
Keynote is a library for defining and instantiating presenters, objects that encapsulate view logic.
Defined Under Namespace
Modules: Cache, Controller, ExampleGroup, Helper, Inline, Rumble, TestPresentMethod Classes: Presenter, Railtie, TestCase
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
-
.present(view, *objects) ⇒ Object
Create or retrieve a presenter wrapping zero or more objects.
Class Method Details
.present(view, *objects) ⇒ Keynote::Presenter .present(view, presenter_name, *objects) ⇒ Keynote::Presenter
Create or retrieve a presenter wrapping zero or more objects. If a block is given, yield the presenter into it.
The first parameter is a Rails view context, but you’ll usually access this method through ‘Keynote::Helper#present`, `Keynote::Controller#present`, or `Keynote::Presenter#present`, all of which handle the view context parameter automatically.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/keynote/core.rb', line 40 def present(view, *objects) name = if objects[0].is_a?(Symbol) || objects[0].is_a?(String) objects.shift else presenter_name_from_object(objects[0]) end Cache.fetch(name, view, *objects) do presenter_from_name(name).new(view, *objects).tap do |presenter| yield presenter if block_given? end end end |