Class: Ecoportal::API::GraphQL::Input::SearchConf::FieldRef

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(key) ⇒ FieldRef

Returns a new instance of FieldRef.



301
302
303
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 301

def initialize(key)
  @key = key
end

Instance Method Details

#any_of(*values, field_key: 'selected') ⇒ Object

Register FIELD value membership → has_any_filter (Select/CrossReference/People/…). Use this for a register field ('select_str.zXXXX'), NOT one_of (which ORs exact_filter and is for system keys). field_key defaults to 'selected' (selects); pass e.g. 'id' for cross_reference. See filter_contract_matrix.md.



321
322
323
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 321

def any_of(*values, field_key: 'selected')
  HasAny.new(@key, values.flatten, field_key: field_key)
end

#before(date, time_zone: 'UTC') ⇒ Object



341
342
343
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 341

def before(date, time_zone: 'UTC')
  DateRange.new(@key, lte: date, time_zone: time_zone)
end

#between(from, til, time_zone: 'UTC') ⇒ Object



345
346
347
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 345

def between(from, til, time_zone: 'UTC')
  DateRange.new(@key, gte: from, lte: til, time_zone: time_zone)
end

#between_nums(min, max) ⇒ Object



373
374
375
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 373

def between_nums(min, max)
  RawFilter.new('numeric_range_filter', key: @key, gte: min, lte: max)
end

#blankObject



361
362
363
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 361

def blank
  RawFilter.new('doesnt_exist_filter', field: @key)
end

#eq(value) ⇒ Object



305
306
307
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 305

def eq(value)
  Exact.new(@key, value)
end

#false?Boolean

Returns:

  • (Boolean)


369
370
371
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 369

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.



351
352
353
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 351

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



309
310
311
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 309

def is(value)
  eq(value.to_s)
end

#matches(text) ⇒ Object



333
334
335
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 333

def matches(text)
  RawFilter.new('match_filter', key: @key, value: text)
end

#none_of(*values, field_key: 'selected') ⇒ Object



325
326
327
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 325

def none_of(*values, field_key: 'selected')
  HasAny.new(@key, values.flatten, field_key: field_key, exclude: true)
end

#not_eq(value) ⇒ Object



329
330
331
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 329

def not_eq(value)
  RawFilter.new('isnt_exact_filter', key: @key, value: value)
end

#one_of(*values) ⇒ Object



313
314
315
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 313

def one_of(*values)
  Or.new(*values.flatten.map { |v| eq(v.to_s) })
end

#presentObject Also known as: exists



355
356
357
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 355

def present
  RawFilter.new('has_any_filter', key: @key)
end

#since(date, time_zone: 'UTC') ⇒ Object



337
338
339
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 337

def since(date, time_zone: 'UTC')
  DateRange.new(@key, gte: date, time_zone: time_zone)
end

#true?Boolean

Returns:

  • (Boolean)


365
366
367
# File 'lib/ecoportal/api/graphql/input/search_conf.rb', line 365

def true?
  RawFilter.new('boolean_filter', key: @key, value: true)
end