module Trailblazer::Finder::Adapters::Basic::Predicates

Basic Predicates Adapter

Public Instance Methods

set_blank_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 28
def set_blank_handler
  lambda do |entity, attribute, _value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && Utils::String.blank?(v.to_s) }, entity
  end
end
set_cont_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 64
def set_cont_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_s.include?(value.to_s) && !v.nil? }, entity
  end
end
set_eq_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 12
def set_eq_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_s == value.to_s && !v.nil? }, entity
  end
end
set_ew_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 96
def set_ew_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_s.end_with?(value.to_s) && !v.nil? }, entity
  end
end
set_gt_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 40
def set_gt_handler
  lambda do |entity, attribute, value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_f > value.to_f }, entity
  end
end
set_gte_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 46
def set_gte_handler
  lambda do |entity, attribute, value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_f >= value.to_f }, entity
  end
end
set_lt_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 52
def set_lt_handler
  lambda do |entity, attribute, value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_f < value.to_f }, entity
  end
end
set_lte_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 58
def set_lte_handler
  lambda do |entity, attribute, value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_i <= value.to_f }, entity
  end
end
set_not_blank_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 34
def set_not_blank_handler
  lambda do |entity, attribute, _value|
    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && !Utils::String.blank?(v.to_s) }, entity
  end
end
set_not_cont_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 72
def set_not_cont_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && !v.to_s.include?(value.to_s) && !v.nil? }, entity
  end
end
set_not_eq_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 20
def set_not_eq_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_s != value.to_s && !v.nil? }, entity
  end
end
set_not_ew_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 104
def set_not_ew_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && !v.to_s.end_with?(value.to_s) && !v.nil? }, entity
  end
end
set_not_sw_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 88
def set_not_sw_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && !v.to_s.start_with?(value.to_s) && !v.nil? }, entity
  end
end
set_sw_handler() click to toggle source
# File lib/trailblazer/finder/adapters/basic/predicates.rb, line 80
def set_sw_handler
  lambda do |entity, attribute, value|
    return if Utils::String.blank?(value.to_s) || Utils::String.blank?(attribute.to_s)

    Utils::Hash.deep_locate ->(k, v, _) { k == attribute.to_sym && v.to_s.start_with?(value.to_s) && !v.nil? }, entity
  end
end