Sha256: d25ee7e0d668a441e36342fe4371a4559a64074630099bb8db2471c504bb465a
Contents?: true
Size: 963 Bytes
Versions: 46
Compression:
Stored size: 963 Bytes
Contents
# subclass built-in Hydra RightsDatastream and build in extra model-level validation class ParanoidRightsDatastream < Hydra::Datastream::RightsMetadata use_terminology Hydra::Datastream::RightsMetadata VALIDATIONS = [ {:key => :edit_users, :message => 'Depositor must have edit access', :condition => lambda { |obj| !obj.edit_users.include?(obj.depositor) }}, {:key => :edit_groups, :message => 'Public cannot have edit access', :condition => lambda { |obj| obj.edit_groups.include?('public') }}, {:key => :edit_groups, :message => 'Registered cannot have edit access', :condition => lambda { |obj| obj.edit_groups.include?('registered') }} ] def validate(object) valid = true VALIDATIONS.each do |validation| if validation[:condition].call(object) object.errors[validation[:key]] ||= [] object.errors[validation[:key]] << validation[:message] valid = false end end return valid end end
Version data entries
46 entries across 46 versions & 2 rubygems