Sha256: 7201e31b76e6789db52604d434cea92f43cdbf78829bd2255b8fb63ac26969a7

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

module CloudSesame
	module Query
		module DSL
			module OperatorMethods

				# NEAR: creates a single NEAR node
				# =======================================
				def near(value, options = {})
					create_literal AST::Near, options, value
				end

				alias_method :sloppy,     :near

				# PREFIX: creates a single PREFIX node
				# =======================================
				def prefix(value, options = {})
					create_literal AST::Prefix, options, value
				end

				alias_method :start_with,	:prefix
				alias_method :begin_with, :prefix

				# PHRASE: creates a single PHRASE node
				# =======================================
				def phrase(value, options = {})
					create_literal AST::Phrase, options, value
				end

				# TERM: creates a single TERM node
				# =======================================
				def term(value, options = {})
					create_literal AST::Term, options, value
				end

				private

				def fields
					dsl_context[:fields]
				end

				def create_literal(klass, options, value)
					(node = klass.new dsl_context, options) << fieldless_literal(value)
					return node
				end

				def fieldless_literal(value)
					AST::Literal.new nil, value
				end

			end
		end
	end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
CloudSesame-0.4.6 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.5 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.4 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.3 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.2 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.1 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.4.0 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.6 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.5 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.4 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.3 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.2 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.1 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.3.0 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.2.5 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.2.4 lib/cloud_sesame/query/dsl/operator_methods.rb
CloudSesame-0.2.3 lib/cloud_sesame/query/dsl/operator_methods.rb