lib/searchlogic/named_scopes/or_conditions.rb
# The purpose of this method is to convert the method name parts into actual condition names.
#
# Example:
#
#   ["first_name", "last_name_like"]
#   => ["first_name_like", "last_name_like"]
#
#   ["id_gt", "first_name_begins_with", "last_name", "middle_name_like"]
#   => ["id_gt", "first_name_begins_with", "last_name_like", "middle_name_like"]
#
# Basically if a column is specified without a condition the next condition in the list
# is what will be used. Once we are able to get a consistent list of conditions we can easily
# create a scope for it.
The purpose of this method is to convert the method name parts into actual condition names.
Example.





Basically if a column is specified without a condition the next condition in the list
is what will be used. Once we are able to get a consistent list of conditions we can easily
create a scope for it.
The purpose of this method is to convert the method name parts into actual condition names . Example . Basically if a column is specified without a condition the next condition in the list is what will be used . Once we are able to get a consistent list of conditions we can easily create a scope for it .
def interpolate_or_conditions(parts)
          conditions = []
          last_condition = nil
          parts.reverse.each do |part|
            if details = condition_details(part)
              conditions << "#{details[:column]}_#{details[:condition]}"
              last_condition = details[:condition]
            elsif details = association_condition_details(part)
            elsif local_condition?(part)
              conditions << part
            elsif column_names.include?(part)
              if last_condition.nil?
                raise NoConditionSpecifiedError.new("The '#{part}' column doesn't know which condition to use, if you use an exact column " +
                  "name you need to specify a condition sometime after (ex: id_or_created_at_lt), where id would use the 'lt' condition.")
              end
              conditions << "#{part}_#{last_condition}"
            else
              raise UnknownConditionError.new("The condition '#{part}' is not a valid condition, we could not find any scopes that match this.")
            end
          end
          conditions.reverse
        end
def interpolate_or_conditions ( parts ) conditions = [ ] last_condition = nil parts . reverse . each do | part | if details = condition_details ( part ) conditions << "#{details[:column]}_#{details[:condition]}" last_condition = details [ :condition ] elsif details = association_condition_details ( part ) elsif local_condition? ( part ) conditions << part elsif column_names . include? ( part ) if last_condition . nil? raise NoConditionSpecifiedError . new ( "The '#{part}' column doesn't know which condition to use, if you use an exact column " + "name you need to specify a condition sometime after (ex: id_or_created_at_lt), where id would use the 'lt' condition." ) end conditions << "#{part}_#{last_condition}" else raise UnknownConditionError . new ( "The condition '#{part}' is not a valid condition, we could not find any scopes that match this." ) end end conditions . reverse end
The purpose of this method is to convert the method name parts into actual condition names.
The purpose of this method is to convert the method name parts into actual condition names .
# We are a searchlogic defined scope # pending, need to find the last condition # We are a custom scope # we are a column, use the last condition
parts
<not_specific>