Closed alexkalderimis closed 2 months ago
I concur with @lessthanjacob. But I'd also like to understand the use-case better. Why would you want to make all fields in a view conditional? If you want to hide all fields, couldn't the caller just make that determination and use a different view?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Prior to this change, applying conditions to a view required annotating all fields individually.
This change allows views to be defined as
view :name, if: condition
, using the same->(field_name, object, options) { ... }
callbacks as used on fields. These callbacks are propagated to the fields, and are in addition to (not in replacement of) any checks defined on the fields.Tests are added to cover the logic of
unless
andif
, andField#skip?
is altered to allow a field to have bothunless
andif
defined.Defining a view-level condition on an child blueprint does not affect the parent view of the same name - this behavior may be unexpected, and it is advised not to add conditions to inherited views, since this may represent a security flaw.
Checklist: