Class: RightsRestriction
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- RightsRestriction
- Defined in:
- backend/app/model/rights_restriction.rb
Class Method Summary collapse
-
.applicable_models ⇒ Object
-
.calculate_applicable_models ⇒ Object
-
.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object
Instance Method Summary collapse
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 |