Class: MARCAuthModel
- Inherits:
-
ASpaceExport::ExportModel
- Object
- ASpaceExport::ExportModel
- MARCAuthModel
- Defined in:
- backend/app/exporters/models/marc_auth.rb
Overview
frozen_string_literal: true
Constant Summary collapse
- RESOLVE =
['subjects', 'places'].freeze
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#related_records ⇒ Object
readonly
Returns the value of attribute related_records.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(obj, events, related_records, repo) ⇒ MARCAuthModel
constructor
A new instance of MARCAuthModel.
-
#maintenanceAgency ⇒ Object
-
#method_missing(meth) ⇒ Object
-
#name_part_fields ⇒ Object
maps name.field => EAC @localType attribute.
-
#related_agents ⇒ Object
Methods inherited from ASpaceExport::ExportModel
#apply_map, inherited, model_for, model_for?
Constructor Details
#initialize(obj, events, related_records, repo) ⇒ MARCAuthModel
Returns a new instance of MARCAuthModel.
57 58 59 60 61 62 63 |
# File 'backend/app/exporters/models/marc_auth.rb', line 57 def initialize(obj, events, , repo) @type = obj.jsonmodel_type @json = URIResolver.resolve_references(obj, RESOLVE) @events = events.map { |e| self.class.instance_variable_get(:@marc_auth_event).new(e) } = @repo = repo end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth) ⇒ Object
81 82 83 |
# File 'backend/app/exporters/models/marc_auth.rb', line 81 def method_missing(meth) @json.send(meth) if @json.respond_to?(meth) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events
69 70 71 |
# File 'backend/app/exporters/models/marc_auth.rb', line 69 def events @events end |
#json ⇒ Object (readonly)
Returns the value of attribute json
6 7 8 |
# File 'backend/app/exporters/models/marc_auth.rb', line 6 def json @json end |
#related_records ⇒ Object (readonly)
Returns the value of attribute related_records
6 7 8 |
# File 'backend/app/exporters/models/marc_auth.rb', line 6 def end |
Class Method Details
.from_agent(obj, events, related_records, repo) ⇒ Object
65 66 67 |
# File 'backend/app/exporters/models/marc_auth.rb', line 65 def self.from_agent(obj, events, , repo) new(obj, events, , repo) end |
Instance Method Details
#maintenanceAgency ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'backend/app/exporters/models/marc_auth.rb', line 71 def maintenanceAgency if @ma.nil? @ma = OpenStruct.new @ma.agencyName = @repo.name @ma.agencyCode = @repo.org_code if @repo.org_code end @ma end |
#name_part_fields ⇒ Object
maps name.field => EAC @localType attribute
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'backend/app/exporters/models/marc_auth.rb', line 94 def name_part_fields case @type when 'agent_person' { 'primary_name' => 'surname', 'title' => 'title', 'prefix' => 'prefix', 'rest_of_name' => 'forename', 'suffix' => 'suffix', 'fuller_form' => 'fuller_form', 'number' => 'numeration', 'qualifier' => 'qualifier', 'dates' => 'dates' } when 'agent_family' { 'prefix' => 'prefix', 'family_name' => 'surname', 'number' => 'numeration', 'qualifier' => 'qualifier', 'location' => 'location', 'dates' => 'dates', 'family_type' => 'family_type' } # TODO: Remove software? when 'agent_software' { 'software_name' => nil, 'version' => nil, 'manufacturer' => nil } when 'agent_corporate_entity' { 'primary_name' => 'primary_name', 'subordinate_name_1' => 'subordinate_name_1', 'subordinate_name_2' => 'subordinate_name_2', 'number' => 'numeration', 'qualifier' => 'qualifier', 'location' => 'location', 'dates' => 'dates' } end end |
#related_agents ⇒ Object
85 86 87 88 89 90 91 |
# File 'backend/app/exporters/models/marc_auth.rb', line 85 def if @json.respond_to?(:related_agents) @json. else [] end end |