Sha256: 95639ac5d7f418522bc6b84130a3f21390083208050bdfe2cc0031db2350a63e
Contents?: true
Size: 895 Bytes
Versions: 10
Compression:
Stored size: 895 Bytes
Contents
class ModelSet module Conditioned # Shared methods for dealing with conditions. attr_reader :conditions def add_conditions!(*conditions) operator = conditions.shift if conditions.first.kind_of?(Symbol) operator ||= :and # Sanitize conditions. conditions.collect! do |condition| condition.kind_of?(Conditions) ? condition : Conditions.new( sanitize_condition(condition) ) end if operator == :not # In this case, :not actually means :and :not. conditions = ~Conditions.new(:and, *conditions) operator = :and end conditions << @conditions if @conditions @conditions = Conditions.new(operator, *conditions) clear_cache! end def invert! raise 'cannot invert without conditions' if @conditions.nil? @conditions = ~@conditions clear_cache! end end end
Version data entries
10 entries across 10 versions & 2 rubygems