Sha256: dcacdeea644111ddd3884a0e32475bad50f50d697166425480591612cb5a3dee

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

module CloudSesame
	module Query
		module DSL
			module BlockMethods

				attr_accessor :orphan_node

				# CLAUSE: AND
				# =========================================
				def and(options = {}, &block)
					block_style_dsl AST::And, options, &block
				end

				alias_method :all,  :and
				alias_method :and!, :and

				# CLAUSE: OR
				# =========================================
				def or(options = {}, &block)
					block_style_dsl AST::Or, options, &block
				end

				alias_method :any, :or
				alias_method :or!, :or

				private

				def block_style_dsl(klass, options, &block)
					node = klass.new dsl_context, options, &block
					if block_given?
						dsl_scope << node
						dsl_return node
					else
						AST::BlockChainingRelation.new(dsl_scope, dsl_return, node)
					end
				end

			end
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
CloudSesame-0.2.3 lib/cloud_sesame/query/dsl/block_methods.rb
CloudSesame-0.2.2 lib/cloud_sesame/query/dsl/block_methods.rb
CloudSesame-0.2.1 lib/cloud_sesame/query/dsl/block_methods.rb
CloudSesame-0.2.0 lib/cloud_sesame/query/dsl/block_methods.rb