Sha256: 1fc9a8f0c23aefa80f76cf40d945d96de797af59b0e3153824a8af4b55c3a82a

Contents?: true

Size: 906 Bytes

Versions: 26

Compression:

Stored size: 906 Bytes

Contents

module Sunspot
  module DSL #:nodoc:
    # 
    # 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
    # Restriction module, with the exception of Base and SameAs. All methods
    # take a single argument, which is the value to be applied to the
    # restriction.
    #
    class Restriction #:nodoc:
      def initialize(field_name, query, negative)
        @field_name, @query, @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)
            @query.add_restriction(@field_name, Sunspot::Query::Restriction::#{class_name}, value, @negative)
          end
        RUBY
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 7 rubygems

Version Path
Chrononaut-sunspot-client-0.9.4 lib/sunspot/dsl/restriction.rb
UnderpantsGnome-sunspot-0.9.1.1 lib/sunspot/dsl/restriction.rb
UnderpantsGnome-sunspot-0.9.8.1 lib/sunspot/dsl/restriction.rb
kristopher-sunspot-0.9.8 lib/sunspot/dsl/restriction.rb
kuahyeow-sunspot-0.9.7 lib/sunspot/dsl/restriction.rb
kuahyeow-sunspot-0.9.8 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.0 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.1 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.2 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.3 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.4 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.5 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.8 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.8.9 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.0 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.1 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.2 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.3 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.4 lib/sunspot/dsl/restriction.rb
outoftime-sunspot-0.9.5 lib/sunspot/dsl/restriction.rb