Module: Tuxedo::ActionView::Helpers
- Defined in:
- lib/tuxedo/action_view/helpers.rb
Overview
Main module for the ActionView helpers
Instance Method Summary collapse
-
#prac(object, method, *args) ⇒ Object
Present And Call Shorthand method for using the following call.
-
#presenter_for(model, klass = nil) {|presenter| ... } ⇒ Object
We can use this to give a block and wrap all the presenter methods in the block.
Instance Method Details
#prac(object, method, *args) ⇒ Object
Present And Call Shorthand method for using the following call
presenter_for(object).zone_label
42 43 44 45 |
# File 'lib/tuxedo/action_view/helpers.rb', line 42 def prac(object, method, *args) return if object.nil? || method.nil? presenter_for(object).send(method.to_sym, *args) end |
#presenter_for(model, klass = nil) {|presenter| ... } ⇒ Object
We can use this to give a block and wrap all the presenter methods in the block. This shows clearly that we are using a presenter without the explicit assign statement. Some magic happens to initiate a new presenter with the model and the view context
21 22 23 24 25 26 27 |
# File 'lib/tuxedo/action_view/helpers.rb', line 21 def presenter_for(model, klass = nil) return if model.nil? klass ||= "#{model.class.name}#{Tuxedo.config.suffix}".constantize presenter = klass.new(model, self) yield presenter if block_given? presenter end |