Module: Cant::Questionable

Included in:
Embeddable, Engine
Defined in:
lib/cant/engine.rb

Overview

questionable interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cantfiguration=(value) ⇒ Object

Sets the attribute cantfiguration

Parameters:

  • value

    the value to set the attribute cantfiguration to.



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

Returns:

  • (Boolean)


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