Sha256: 49361e2a94d54b429d4359bcc16406a0a1a714afd461a544bed58949d9063fe4
Contents?: true
Size: 983 Bytes
Versions: 2
Compression:
Stored size: 983 Bytes
Contents
class Parelation::Criteria::Where < Parelation::Criteria require_relative "where/caster" require_relative "where/directional_query_applier" require_relative "where/criteria_builder" # @return [Regexp] the "where" format. # WHERE_FORMAT = /^(where|where_(not|gt|gte|lt|lte))$/ # @param param [String] # @return [true, false] # def self.match?(param) !!param.match(WHERE_FORMAT) end # @return [ActiveRecord::Relation] # def call criteria.inject(chain) do |chain, (field, value)| case param when "where" chain.where(field => value) when "where_not" chain.where.not(field => value) when "where_gt", "where_gte", "where_lt", "where_lte" DirectionalQueryApplier.new(chain, param, field, value).apply end end end private # @return [Hash] containing data used to pass to {#chain}'s +where+ method. # def criteria @criteria ||= CriteriaBuilder.new(value, chain).build end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
parelation-1.0.0 | lib/parelation/criteria/where.rb |
parelation-0.2.0 | lib/parelation/criteria/where.rb |