Class: Condition
- Inherits:
-
Object
- Object
- Condition
- Defined in:
- lib/embed_callbacks/condition.rb
Instance Method Summary collapse
- #call(record) ⇒ Object
-
#initialize(options) ⇒ Condition
constructor
A new instance of Condition.
Constructor Details
#initialize(options) ⇒ Condition
Returns a new instance of Condition.
2 3 4 5 6 |
# File 'lib/embed_callbacks/condition.rb', line 2 def initialize() @if = [:if] @unless = [:unless] raise ArgumentError, "Don't use if and unless at the same time." if @if && @unless end |
Instance Method Details
#call(record) ⇒ Object
8 9 10 11 12 |
# File 'lib/embed_callbacks/condition.rb', line 8 def call(record) return @if.call(record) if @if return !@unless&.call(record) if @unless true end |