Class: Triggerable::Conditions::Exists

Inherits:
FieldCondition show all
Defined in:
lib/triggerable/conditions/field/exists.rb

Instance Method Summary collapse

Methods inherited from FieldCondition

#initialize

Methods inherited from Condition

build

Constructor Details

This class inherits a constructor from Triggerable::Conditions::FieldCondition

Instance Method Details

#descObject



13
14
15
# File 'lib/triggerable/conditions/field/exists.rb', line 13

def desc
  "#{@field} exists"
end

#scopeObject



9
10
11
# File 'lib/triggerable/conditions/field/exists.rb', line 9

def scope
  "#{@field} IS #{'NOT ' if @value}NULL"
end

#true_for?(object) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
# File 'lib/triggerable/conditions/field/exists.rb', line 4

def true_for? object
  v = field_value(object)
  @value ? v.present? : v.blank?
end