Sha256: 518d3cab211864400725aa5ed9faed9331fc01f4c7ae1cb9dabcaee36499076c

Contents?: true

Size: 877 Bytes

Versions: 56

Compression:

Stored size: 877 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, scope, negative) #:nodoc:
        @field, @scope, @negative = field, scope, 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(@negative, @field, Sunspot::Query::Restriction::#{class_name}, *value)
          end
        RUBY
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 10 rubygems

Version Path
sunspot-2.7.1 lib/sunspot/dsl/restriction.rb
sunspot-2.7.0 lib/sunspot/dsl/restriction.rb
sunspot-2.6.0 lib/sunspot/dsl/restriction.rb
sunspot-2.5.0 lib/sunspot/dsl/restriction.rb
sunspot-2.4.0 lib/sunspot/dsl/restriction.rb
sunspot-2.3.0 lib/sunspot/dsl/restriction.rb
sunspot-2.2.8 lib/sunspot/dsl/restriction.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sunspot-2.2.7/lib/sunspot/dsl/restriction.rb
sunspot-2.2.7 lib/sunspot/dsl/restriction.rb
sunspot-2.2.6 lib/sunspot/dsl/restriction.rb
sunspot-2.2.5 lib/sunspot/dsl/restriction.rb
sunspot-2.2.4 lib/sunspot/dsl/restriction.rb
sunspot-2.2.3 lib/sunspot/dsl/restriction.rb
sunspot-2.2.2 lib/sunspot/dsl/restriction.rb
sunspot-2.2.1 lib/sunspot/dsl/restriction.rb
sunspot-2.2.0 lib/sunspot/dsl/restriction.rb
sunspot-2.1.1 lib/sunspot/dsl/restriction.rb
sunspot-2.1.0 lib/sunspot/dsl/restriction.rb
sunspot-2.0.0 lib/sunspot/dsl/restriction.rb
sunspot-2.0.0.pre.130115 lib/sunspot/dsl/restriction.rb