Sha256: 642cfd06150fde818e955d6e870d9d63811493e3e3604e6aa8eb26c5c6d1e1a7

Contents?: true

Size: 438 Bytes

Versions: 4

Compression:

Stored size: 438 Bytes

Contents

module Searchgasm
  module Condition
    class ChildOf < Tree      
      def to_conditions(value)
        parent_association = klass.reflect_on_association(:parent)
        foreign_key_name = (parent_association && parent_association.options[:foreign_key]) || "parent_id"
        ["#{quoted_table_name}.#{quote_column_name(foreign_key_name)} = ?", (value.is_a?(klass) ? value.send(klass.primary_key) : value)]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
searchgasm-1.5.0 lib/searchgasm/condition/child_of.rb
searchgasm-1.5.1 lib/searchgasm/condition/child_of.rb
searchgasm-1.5.2 lib/searchgasm/condition/child_of.rb
searchgasm-1.5.3 lib/searchgasm/condition/child_of.rb