Sha256: 8b2aaf3e5910638b05a6c660a340b1f36dafd96c19c32588eb443be96894a334

Contents?: true

Size: 858 Bytes

Versions: 13

Compression:

Stored size: 858 Bytes

Contents

module CloudSesame
	module Query
		module DSL
			module FilterQueryMethods

				def included?(field, value = nil)
					(field_options = dsl_context[:fields][field]) && (
						(value && field_options_is(:included, field_options, value)) ||
						(!value && field_options_not_empty_in(:included, field_options))
					)
				end

				def excluded?(field, value = nil)
					(field_options = dsl_context[:fields][field]) && (
						(value && field_options_is(:excluded, field_options, value)) ||
						(!value && field_options_not_empty_in(:excluded, field_options))
					)
				end

				private

				def field_options_is(type, field_options, value)
					(values = field_options[type]) && values.include?(value)
				end

				def field_options_not_empty_in(type, field_options)
					field_options[type] && !field_options[type].empty?
				end

			end
		end
	end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
CloudSesame-0.3.6 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.5 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.4 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.3 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.2 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.1 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.3.0 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.5 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.4 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.3 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.2 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.1 lib/cloud_sesame/query/dsl/filter_query_methods.rb
CloudSesame-0.2.0 lib/cloud_sesame/query/dsl/filter_query_methods.rb