Sha256: e890905a9f93af76721fb6a5e217cce708aa51dfbe4e7b21cbd0594a93ba78cd

Contents?: true

Size: 656 Bytes

Versions: 8

Compression:

Stored size: 656 Bytes

Contents

module Searchlogic
  module Condition
    class SiblingOf < NestedSet
      def to_conditions(value)
        parent_association = klass.reflect_on_association(:parent)
        foreign_key_name = (parent_association && parent_association.options[:foreign_key]) || "parent_id"
        parent_id = (value.is_a?(klass) ? value : klass.find(value)).send(foreign_key_name)
        condition = ChildOf.new(klass, options)
        condition.value = parent_id
        merge_conditions(["#{quoted_table_name}.#{quote_column_name(klass.primary_key)} != ?", (value.is_a?(klass) ? value.send(klass.primary_key) : value)], condition.sanitize)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
schof-searchlogic-0.0.2 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.1 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.0 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.6 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.2 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.3 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.5 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.6.4 lib/searchlogic/condition/sibling_of.rb