Sha256: 1880e570770a693bd0cf9e0cf9b8d464893ed2f347ba98bf7584d6fd7d3432af

Contents?: true

Size: 895 Bytes

Versions: 25

Compression:

Stored size: 895 Bytes

Contents

module Sunspot
  module DSL
    # 
    # This class presents an API for building restrictions in the query DSL. The
    # methods exposed are the snake-cased names of the classes defined in the
    # Sunspot::Restriction module, with the exception of Base. All
    # methods take a single argument, which is the value to be applied to the
    # restriction.
    #
    class Restriction
      def initialize(field_name, query, negative) #:nodoc:
        @field_name, @scope, @negative = field_name, query, negative
      end

      Sunspot::Query::Restriction.names.each do |class_name|
        method_name = Util.snake_case(class_name.to_s)
        module_eval(<<-RUBY, __FILE__, __LINE__ + 1)
          def #{method_name}(value)
            @scope.add_restriction(@field_name, Sunspot::Query::Restriction::#{class_name}, value, @negative)
          end
        RUBY
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
ruben-sunspot-1.1.4 lib/sunspot/dsl/restriction.rb
ruben-sunspot-1.1.3 lib/sunspot/dsl/restriction.rb
ruben-sunspot-1.1.2 lib/sunspot/dsl/restriction.rb
ruben-sunspot-1.1.1 lib/sunspot/dsl/restriction.rb
ruben-sunspot-1.1.0 lib/sunspot/dsl/restriction.rb
nuatt_sunspot-1.1.0.3 lib/sunspot/dsl/restriction.rb
sunspot-1.1.0 lib/sunspot/dsl/restriction.rb
sunspot-1.0.5 lib/sunspot/dsl/restriction.rb
sunspot-1.0.4 lib/sunspot/dsl/restriction.rb
sunspot-1.0.3 lib/sunspot/dsl/restriction.rb
sunspot-1.0.2 lib/sunspot/dsl/restriction.rb
sunspot-1.0.1 lib/sunspot/dsl/restriction.rb
sunspot-1.0.0 lib/sunspot/dsl/restriction.rb
sunspot-0.10.9 lib/sunspot/dsl/restriction.rb
sunspot-0.10.8 lib/sunspot/dsl/restriction.rb
nxa-sunspot-0.10.7 lib/sunspot/dsl/restriction.rb
sunspot-0.10.7 lib/sunspot/dsl/restriction.rb
sunspot-0.10.6 lib/sunspot/dsl/restriction.rb
sunspot-0.10.5 lib/sunspot/dsl/restriction.rb
sunspot-0.10.4 lib/sunspot/dsl/restriction.rb