class Condition

Public Class Methods

new(options) click to toggle source
# File lib/embed_callbacks/condition.rb, line 2
def initialize(options)
  @if = options[:if]
  @unless = options[:unless]
  raise ArgumentError, "Don't use if and unless at the same time." if @if && @unless
end

Public Instance Methods

call(record) click to toggle source
# 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