class Realize::Filter::ByKeyValuePresence

This transformer can take an object (will be converted to array) or array and will go through each child object and see if the child record has a value for the specified key. If it does then it will select that record.

Attributes

key[R]

Public Class Methods

new(key:) click to toggle source
# File lib/realize/filter/by_key_value_presence.rb, line 21
def initialize(key:)
  raise ArgumentError, 'key is required' if key.to_s.empty?

  @key = key

  freeze
end

Public Instance Methods

transform(resolver, value, _time, _record) click to toggle source
# File lib/realize/filter/by_key_value_presence.rb, line 29
def transform(resolver, value, _time, _record)
  records = array(value)

  records.reject do |record|
    resolver.get(record, key).to_s.empty?
  end
end