121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/linked_rails/policy.rb', line 121
def condition_for(attr, pass, shape_opts = {})
raise("#{attr} not permitted by #{self}") if attribute_options(attr).blank? && pass.permission_required?
alternatives = node_shapes_for(attr, **shape_opts)
if alternatives.count == 1
Condition.new(shape: alternatives.first, pass: pass)
elsif alternatives.count.positive?
Condition.new(shape: SHACL::NodeShape.new(or: alternatives), pass: pass)
else
pass
end
end
|