Class: ODRL::Policy
Direct Known Subclasses
Set
Instance Attribute Summary collapse
Attributes inherited from Base
#baseURI, #creator, #description, #id, #issued, #label, #subject, #title, #type, #uid
Instance Method Summary
collapse
Methods inherited from Base
baseURI, clear_repository, #get_writer, getuuid, repository, #repository, #triplify
Constructor Details
#initialize(uid: nil, type: CPOLICY, **args) ⇒ Policy
Returns a new instance of Policy.
11
12
13
14
15
16
17
18
|
# File 'lib/odrl/policy.rb', line 11
def initialize(uid: nil, type: CPOLICY, **args)
@uid = uid
self.uid = Base.baseURI + "#policy_" + Base.getuuid unless @uid
super(uid: @uid, type: type, **args)
@rules = {}
@profiles = {}
end
|
Instance Attribute Details
#profiles ⇒ Object
Returns the value of attribute profiles.
9
10
11
|
# File 'lib/odrl/policy.rb', line 9
def profiles
@profiles
end
|
#rules ⇒ Object
Returns the value of attribute rules.
9
10
11
|
# File 'lib/odrl/policy.rb', line 9
def rules
@rules
end
|
Instance Method Details
#addDuty(rule:) ⇒ Object
20
21
22
23
|
# File 'lib/odrl/policy.rb', line 20
def addDuty(rule:)
uid = rule.uid
rules[uid] = [POBLIGATION, rule]
end
|
#addPermission(rule:) ⇒ Object
25
26
27
28
|
# File 'lib/odrl/policy.rb', line 25
def addPermission(rule:)
uid = rule.uid
rules[uid] = [PPERMISSION, rule]
end
|
#addProfile(profile:) ⇒ Object
35
36
37
38
|
# File 'lib/odrl/policy.rb', line 35
def addProfile(profile:)
uid = profile.uid
profiles[uid] = [PPROFILE, uid]
end
|
#addProhibition(rule:) ⇒ Object
30
31
32
33
|
# File 'lib/odrl/policy.rb', line 30
def addProhibition(rule:)
uid = rule.uid
rules[uid] = [PPROHIBITION, rule]
end
|
#load_graph ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/odrl/policy.rb', line 40
def load_graph
super
rules.each do |_uid, rulepair|
predicate, ruleobject = rulepair object = ruleobject.uid
subject = uid
repo = repository
triplify(subject, predicate, object, repo)
ruleobject.load_graph end
profiles.each do |_uid, profile_pair|
predicate, profileuri = profile_pair object = profileuri
subject = uid
repo = repository
triplify(subject, predicate, object, repo)
end
end
|
#serialize(format:) ⇒ Object
62
63
64
|
# File 'lib/odrl/policy.rb', line 62
def serialize(format:)
super
end
|