module Trailblazer::Finder::Adapters::ActiveRecord::Predicates

ActiveRecord Predicates Adapter

Public Instance Methods

set_blank_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 28
def set_blank_handler
  lambda do |entity, attribute, _value|
    entity.where(attribute.to_sym => [nil, ""])
  end
end
set_cont_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 64
def set_cont_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} LIKE ?", "%#{value}%")
  end
end
set_eq_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 12
def set_eq_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s)

    entity.where(attribute => value)
  end
end
set_ew_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 88
def set_ew_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} LIKE ?", "%#{value}")
  end
end
set_gt_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 40
def set_gt_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} > ?", value.to_f)
  end
end
set_gte_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 46
def set_gte_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} >= ?", value.to_f)
  end
end
set_lt_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 52
def set_lt_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} < ?", value.to_f)
  end
end
set_lte_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 58
def set_lte_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} <= ?", value.to_f)
  end
end
set_not_blank_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 34
def set_not_blank_handler
  lambda do |entity, attribute, _value|
    entity.where.not(attribute.to_sym => [nil, ""])
  end
end
set_not_cont_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 70
def set_not_cont_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} NOT LIKE ?", "%#{value}%")
  end
end
set_not_eq_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 20
def set_not_eq_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s)

    entity.where.not(attribute => value)
  end
end
set_not_ew_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 94
def set_not_ew_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} NOT LIKE ?", "%#{value}")
  end
end
set_not_sw_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 82
def set_not_sw_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} NOT LIKE ?", "#{value}%")
  end
end
set_sw_handler() click to toggle source
# File lib/trailblazer/finder/adapters/active_record/predicates.rb, line 76
def set_sw_handler
  lambda do |entity, attribute, value|
    entity.where("#{attribute} LIKE ?", "#{value}%")
  end
end