class Triggerable::Conditions::FieldCondition

Public Class Methods

new(field, value) click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 4
def initialize field, value
  @field = field
  @value = value
end

Public Instance Methods

desc() click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 17
def desc
  "#{@field} #{@ruby_comparator} #{@value}"
end
scope(table) click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 13
def scope table
  table[@field].send(@db_comparator, @value)
end
true_for?(object) click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 9
def true_for? object
  field_value(object).send(@ruby_comparator, @value)
end

Private Instance Methods

field_value(object) click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 22
def field_value object
  object.send(@field)
end
sanitized_value() click to toggle source
# File lib/triggerable/conditions/field/field_condition.rb, line 26
def sanitized_value
  if @value.is_a?(Array)
    @value.map { |v| ActiveRecord::Base::sanitize(v) }
  else
    ActiveRecord::Base::sanitize(@value)
  end
end