lib/searchlogic/search.rb
def method_missing(name, *args, &block)
        condition_name = condition_name(name)
        scope_name = scope_name(condition_name)
        
        if setter?(name)
          if scope?(scope_name)
            if args.size == 1
              write_condition(
                condition_name,
                type_cast(
                  args.first,
                  cast_type(scope_name),
                  scope_options(scope_name).respond_to?(:searchlogic_options) ? scope_options(scope_name).searchlogic_options : {}
                )
              )
            else
              write_condition(condition_name, args)
            end
          else
            raise UnknownConditionError.new(condition_name)
          end
        elsif scope?(scope_name) && args.size <= 1
          if args.size == 0
            read_condition(condition_name)
          else
            send("#{condition_name}=", *args)
            self
          end
        else
          scope = conditions_array.inject(klass.scoped(current_scope) || {}) do |scope, condition|
            scope_name, value = condition
            scope_name = normalize_scope_name(scope_name)
            klass.send(scope_name, value) if !klass.respond_to?(scope_name)
            arity = klass.named_scope_arity(scope_name)
            
            if !arity || arity == 0
              if value == true
                scope.send(scope_name)
              else
                scope
              end
            elsif arity == -1
              scope.send(scope_name, *(value.is_a?(Array) ? value : [value]))
            else
              scope.send(scope_name, value)
            end
          end
          scope.send(name, *args, &block)
        end
      end
# Responsible for adding a "search" method into your models.
Responsible for adding a "search" method into your models.
Responsible for adding a " search " method into your models .
def method_missing(name, *args, &block)
        condition_name = condition_name(name)
        scope_name = scope_name(condition_name)
        if setter?(name)
          if scope?(scope_name)
            if args.size == 1
              write_condition(
                condition_name,
                type_cast(
                  args.first,
                  cast_type(scope_name),
                  scope_options(scope_name).respond_to?(:searchlogic_options) ? scope_options(scope_name).searchlogic_options : {}
                )
              )
            else
              write_condition(condition_name, args)
            end
          else
            raise UnknownConditionError.new(condition_name)
          end
        elsif scope?(scope_name) && args.size <= 1
          if args.size == 0
            read_condition(condition_name)
          else
            send("#{condition_name}=", *args)
            self
          end
        else
          scope = conditions_array.inject(klass.scoped(current_scope) || {}) do |scope, condition|
            scope_name, value = condition
            scope_name = normalize_scope_name(scope_name)
            klass.send(scope_name, value) if !klass.respond_to?(scope_name)
            arity = klass.named_scope_arity(scope_name)
            if !arity || arity == 0
              if value == true
                scope.send(scope_name)
              else
                scope
              end
            elsif arity == -1
              scope.send(scope_name, *(value.is_a?(Array) ? value : [value]))
            else
              scope.send(scope_name, value)
            end
          end
          scope.send(name, *args, &block)
        end
      end
def method_missing ( name , * args , & block ) condition_name = condition_name ( name ) scope_name = scope_name ( condition_name ) if setter? ( name ) if scope? ( scope_name ) if args . size == 1 write_condition ( condition_name , type_cast ( args . first , cast_type ( scope_name ) , scope_options ( scope_name ) . respond_to? ( :searchlogic_options ) ? scope_options ( scope_name ) . searchlogic_options : { } ) ) else write_condition ( condition_name , args ) end else raise UnknownConditionError . new ( condition_name ) end elsif scope? ( scope_name ) && args . size <= 1 if args . size == 0 read_condition ( condition_name ) else send ( "#{condition_name}=" , * args ) self end else scope = conditions_array . inject ( klass . scoped ( current_scope ) || { } ) do | scope , condition | scope_name , value = condition scope_name = normalize_scope_name ( scope_name ) klass . send ( scope_name , value ) if ! klass . respond_to? ( scope_name ) arity = klass . named_scope_arity ( scope_name ) if ! arity || arity == 0 if value == true scope . send ( scope_name ) else scope end elsif arity == - 1 scope . send ( scope_name , * ( value . is_a? ( Array ) ? value : [ value ] ) ) else scope . send ( scope_name , value ) end end scope . send ( name , * args , & block ) end end
Responsible for adding a "search" method into your models.
Responsible for adding a " search " method into your models .
name
args
block