class Parelation::Criteria::Where
Constants
- WHERE_FORMAT
@return [Regexp] the “where” format.
Public Class Methods
match?(param)
click to toggle source
@param param [String] @return [true, false]
# File lib/parelation/criteria/where.rb, line 14 def self.match?(param) !!param.match(WHERE_FORMAT) end
Public Instance Methods
call()
click to toggle source
@return [ActiveRecord::Relation]
# File lib/parelation/criteria/where.rb, line 20 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 Instance Methods
criteria()
click to toggle source
@return [Hash] containing data used to pass to {#chain}'s where
method.
# File lib/parelation/criteria/where.rb, line 37 def criteria @criteria ||= CriteriaBuilder.new(value, chain).build end