Module: Condi
- Defined in:
- lib/condi.rb
Overview
Include this module in an ActionController to define predicates or synonyms within an action context that can be used later in the related action view.
Instance Method Summary collapse
-
#predicate(method_name, &block) ⇒ Object
(also: #synonym)
define a method on the controller which is callable from the related view and returns a true or false value.
Instance Method Details
#predicate(method_name, &block) ⇒ Object Also known as: synonym
Note:
A synonym is an alias for defining methods that return values other than true or false.
Note:
You are not required to end a predicate with a question mark, however it is conventional in Ruby to do so.
define a method on the controller which is callable from the related view and returns a true or false value.
34 35 36 37 38 39 |
# File 'lib/condi.rb', line 34 def predicate(method_name, &block) self.class.instance_eval do define_method(method_name, &block) helper_method(method_name) end end |