Class: RightsRestriction
Class Method Summary
collapse
Instance Method Summary
collapse
#apply_nested_records, #delete, #eagerly_load!, included, #map_validation_to_json_property, #mark_as_system_modified, #remove_nested_records, set_audit_fields, #system_modified?, #update_from_json, #validate
included, #publish!, #set_suppressed, #unpublish!, #uri
Class Method Details
.applicable_models ⇒ Object
23
24
25
|
# File 'backend/app/model/rights_restriction.rb', line 23
def self.applicable_models
@applicable_models ||= calculate_applicable_models
end
|
.calculate_applicable_models ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'backend/app/model/rights_restriction.rb', line 28
def self.calculate_applicable_models
result = {}
models_supporting_rights_restrictions = ASModel.all_models.select {|model| model.included_modules.include?(RightsRestrictionNotes)}
models_supporting_rights_restrictions.each do |model|
join_column = model.association_reflection(:rights_restriction)[:key]
result[join_column] = model
end
result
end
|
.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'backend/app/model/rights_restriction.rb', line 43
def self.sequel_to_jsonmodel(objs, opts = {})
jsons = super
jsons.zip(objs).each do |json, obj|
json['local_access_restriction_type'] = obj.rights_restriction_type.map {|obj| obj.values[:restriction_type]}
json['linked_records'] = {'ref' => obj.linked_record_uri}
end
jsons
end
|
Instance Method Details
#linked_record_uri ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'backend/app/model/rights_restriction.rb', line 12
def linked_record_uri
self.class.applicable_models.each do |column, model|
if self[column]
return model.uri_for(model.my_jsonmodel.record_type, self[column])
end
end
nil
end
|