Skip to content

Commit

Permalink
add read write access rules for agent and identifier models
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jun 16, 2023
1 parent 453f56c commit 892a307
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ontologies_linked_data/models/agents/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ class Agent < LinkedData::Models::Base

attribute :identifiers, namespace: :adms, property: :identifier, enforce: %i[Identifier list]
attribute :affiliations, enforce: %i[Agent list]
attribute :creator, type: :user, enforce: :existence

embed :identifiers, :affiliations

write_access :creator
access_control_load :creator
end
end
end
5 changes: 5 additions & 0 deletions lib/ontologies_linked_data/models/agents/indentifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ class AgentIdentifier < LinkedData::Models::Base
attribute :notation, namespace: :skos, enforce: %i[unique existence]
attribute :schemaAgency, namespace: :adms, enforcedValues: IDENTIFIER_SCHEMES.keys, enforce: [:existence]
attribute :schemeURI, handler: :scheme_uri_infer
attribute :creator, type: :user, enforce: :existence

embedded true

write_access :creator
access_control_load :creator

def scheme_uri_infer
self.bring(:schemaAgency) if self.bring?(:schemaAgency)
IDENTIFIER_SCHEMES[self.schemaAgency.to_sym] if self.schemaAgency
Expand Down

0 comments on commit 892a307

Please sign in to comment.