Class: Ecoportal::API::GraphQL::Input::SearchConf::FieldRef
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Input::SearchConf::FieldRef
- Defined in:
- lib/ecoportal/api/graphql/input/search_conf.rb
Overview
FieldRef — intermediate object produced by SearchConf[:field]. Calling an operation method returns a concrete Composable filter object.
Instance Method Summary collapse
- #before(date, time_zone: 'UTC') ⇒ Object
- #between(from, til, time_zone: 'UTC') ⇒ Object
- #between_nums(min, max) ⇒ Object
- #blank ⇒ Object
- #eq(value) ⇒ Object
- #false? ⇒ Boolean
-
#in_period(mode, time_zone: 'Pacific/Auckland', **extra) ⇒ Object
Human date mode — Search[:updated_at].in_period(:last_month) See search_filters.md for full list of mode values.
-
#initialize(key) ⇒ FieldRef
constructor
A new instance of FieldRef.
- #is(value) ⇒ Object
- #matches(text) ⇒ Object
- #not_eq(value) ⇒ Object
- #one_of(*values) ⇒ Object
- #present ⇒ Object (also: #exists)
- #since(date, time_zone: 'UTC') ⇒ Object
- #true? ⇒ Boolean
Constructor Details
#initialize(key) ⇒ FieldRef
Returns a new instance of FieldRef.
244 245 246 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 244 def initialize(key) @key = key end |
Instance Method Details
#before(date, time_zone: 'UTC') ⇒ Object
272 273 274 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 272 def before(date, time_zone: 'UTC') DateRange.new(@key, lte: date, time_zone: time_zone) end |
#between(from, til, time_zone: 'UTC') ⇒ Object
276 277 278 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 276 def between(from, til, time_zone: 'UTC') DateRange.new(@key, gte: from, lte: til, time_zone: time_zone) end |
#between_nums(min, max) ⇒ Object
304 305 306 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 304 def between_nums(min, max) RawFilter.new('numeric_range_filter', key: @key, gte: min, lte: max) end |
#blank ⇒ Object
292 293 294 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 292 def blank RawFilter.new('doesnt_exist_filter', field: @key) end |
#eq(value) ⇒ Object
248 249 250 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 248 def eq(value) Exact.new(@key, value) end |
#false? ⇒ Boolean
300 301 302 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 300 def false? RawFilter.new('boolean_filter', key: @key, value: false) end |
#in_period(mode, time_zone: 'Pacific/Auckland', **extra) ⇒ Object
Human date mode — Search[:updated_at].in_period(:last_month) See search_filters.md for full list of mode values.
282 283 284 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 282 def in_period(mode, time_zone: 'Pacific/Auckland', **extra) RawFilter.new('date_filter', key: @key, mode: mode.to_s, time_zone: time_zone, **extra) end |
#is(value) ⇒ Object
252 253 254 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 252 def is(value) eq(value.to_s) end |
#matches(text) ⇒ Object
264 265 266 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 264 def matches(text) RawFilter.new('match_filter', key: @key, value: text) end |
#not_eq(value) ⇒ Object
260 261 262 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 260 def not_eq(value) RawFilter.new('isnt_exact_filter', key: @key, value: value) end |
#one_of(*values) ⇒ Object
256 257 258 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 256 def one_of(*values) Or.new(*values.flatten.map { |v| eq(v.to_s) }) end |
#present ⇒ Object Also known as: exists
286 287 288 |
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 286 def present RawFilter.new('has_any_filter', key: @key) end |