You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The block you pass to the match method is executed at build time (once), it's not executed again during the params processing. It's used to define a schema.
You should probably use map here, if you want to deal with arbitrary values:
map:some_valuedo |some_value:|
# Check and apply transformationsend
Is it possible to get the actual value of matching objects in the
match
block?For example, let's say we have this code:
In this case
some_value
should includetrue
to match the condition. But what if it contains some other value, and we want to usesome_value.is_a?(TrueClass)
or any other custom condition forsome_value
to proceed with thehaving
block?For example:
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.The text was updated successfully, but these errors were encountered: