rubanok icon indicating copy to clipboard operation
rubanok copied to clipboard

Get values of filters in `match` block

Open feruzoripov opened this issue 4 months ago • 1 comments

Is it possible to get the actual value of matching objects in the match block? For example, let's say we have this code:

class SomePlane < Rubanok::Plane
  process :filter do
    match :some_value do
      having true do
        # ...
      end
    end
  end
end

In this case some_value should include true to match the condition. But what if it contains some other value, and we want to use some_value.is_a?(TrueClass) or any other custom condition for some_value to proceed with the having block? For example:

class SomePlane < Rubanok::Plane
  process :filter do
    match :some_value do |some_value:|
      having some_value.is_a?(TrueClass) || some_value.blank? do
        # ...
      end
    end
  end
end

Maybe it's already possible to use it like this, but I am not sure, it's not included in README, and I tried to write a code like this and it doesn't work.

feruzoripov avatar Feb 28 '24 04:02 feruzoripov