Class: Searchgasm::Condition::SiblingOf
- Defined in:
- lib/searchgasm/condition/sibling_of.rb
Instance Attribute Summary
Attributes inherited from Base
#column, #column_for_type_cast, #column_sql, #column_sql_format, #klass, #table_name
Instance Method Summary collapse
Methods inherited from Tree
condition_names_for_column, condition_names_for_model
Methods inherited from Base
condition_names_for_column, condition_names_for_model, condition_type_name, #explicitly_set_value=, #explicitly_set_value?, handle_array_value?, ignore_meaningless_value?, #initialize, join_arrays_with_or?, #options, #sanitize, #value, #value=, #value_is_meaningless?
Constructor Details
This class inherits a constructor from Searchgasm::Condition::Base
Instance Method Details
#to_conditions(value) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/searchgasm/condition/sibling_of.rb', line 4 def to_conditions(value) parent_association = klass.reflect_on_association(:parent) foreign_key_name = (parent_association && parent_association.[:foreign_key]) || "parent_id" parent_id = (value.is_a?(klass) ? value : klass.find(value)).send(foreign_key_name) condition = ChildOf.new(klass, ) 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 |