Sha256: e3097c6fcfd59e93796fbbcce765e77bf42de548e61400982336069609b4dbf4

Contents?: true

Size: 651 Bytes

Versions: 7

Compression:

Stored size: 651 Bytes

Contents

module Searchlogic
  module Condition
    class SiblingOf < Tree
      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

7 entries across 7 versions & 1 rubygems

Version Path
searchlogic-1.5.8 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.3 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.6 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.10 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.7 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.4 lib/searchlogic/condition/sibling_of.rb
searchlogic-1.5.9 lib/searchlogic/condition/sibling_of.rb