Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5622daac5e
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 16 lines (15 sloc) 0.692 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
module Searchgasm
  module Condition
    class SiblingOf < Tree
      include Searchgasm::Utilities
      
      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, column)
        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
Something went wrong with that request. Please try again.