Sha256: 74257541f714e3d1c44ea80c33530a798df8a348db06d305d13bc5f2bf28c533
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Searchlogic module Conditions # = Groups # # Allows you to group conditions, similar to how you would group conditions with parenthesis in an SQL statement. See the "Group conditions" section in the READM for examples. module Groups def self.included(klass) klass.class_eval do end end # Creates a new group object to set condition off of. See examples at top of class on how to use this. def group(&block) obj = self.class.new yield obj if block_given? objects << obj obj end # Lets you conditions to be groups or an array of conditions to be put in their own group. Each item in the array will create a new group. This is nice for using # groups in forms. def group=(value) case value when Array value.each { |v| group.conditions = v } else group.conditions = value end end private def group_objects objects.select { |object| object.class == self.class } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
searchlogic-1.5.6 | lib/searchlogic/conditions/groups.rb |