Module: Cant::Questionable
- Included in:
- Embeddable, Engine
- Defined in:
- lib/cant/engine.rb
Overview
questionable interface
Instance Attribute Summary collapse
-
#cantfiguration ⇒ Object
writeonly
Sets the attribute cantfiguration.
Instance Method Summary collapse
-
#cant?(*args) ⇒ Boolean
Public : verify whether you cant.
-
#die_if_cant!(*args) ⇒ Object
Public : run die code if you cant.
Instance Attribute Details
#cantfiguration=(value) ⇒ Object
Sets the attribute cantfiguration
104 105 106 |
# File 'lib/cant/engine.rb', line 104 def cantfiguration=(value) @cantfiguration = value end |
Instance Method Details
#cant?(*args) ⇒ Boolean
Public : verify whether you cant
*args - list of params to pass to rules
Returns : a rule that cant, according rules folding, or nil
91 92 93 |
# File 'lib/cant/engine.rb', line 91 def cant?(*args) cantfiguration.fold.call(cantfiguration.rules, self, *args) end |
#die_if_cant!(*args) ⇒ Object
Public : run die code if you cant
*args - list of params to pass to rules and die function
Returns : die result or nil if it can
99 100 101 102 |
# File 'lib/cant/engine.rb', line 99 def die_if_cant!(*args) rule = cant?(*args) rule.die!(*args) if rule end |