Class: EADModel
- Inherits:
-
ASpaceExport::ExportModel
show all
- Includes:
- ASpaceExport::ArchivalObjectDescriptionHelpers, ASpaceExport::LazyChildEnumerations
- Defined in:
- backend/app/exporters/models/ead.rb
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
#children_indexes, #get_child
#archdesc_dates, #archdesc_note_types, #bibliographies, #controlaccess_linked_agents, #controlaccess_subjects, #did_note_types, #index_item_type_map, #indexes
#apply_map, inherited, model_for, model_for?
#extract_date_string, #extract_note_content, #get_subnotes_by_type
Constructor Details
- (EADModel) initialize(obj, opts)
Returns a new instance of EADModel
58
59
60
61
62
63
64
65
66
67
68
|
# File 'backend/app/exporters/models/ead.rb', line 58
def initialize(obj, opts)
@json = obj
opts.each do |k, v|
self.instance_variable_set("@#{k}", v)
end
repo_ref = obj.repository['ref']
@repo_id = JSONModel::JSONModel(:repository).id_for(repo_ref)
@repo = Repository.to_jsonmodel(@repo_id)
@children = @json.tree['_resolved']['children']
@child_class = self.class.instance_variable_get(:@ao)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(meth)
76
77
78
79
80
81
82
83
84
|
# File 'backend/app/exporters/models/ead.rb', line 76
def method_missing(meth)
if self.instance_variable_get("@#{meth.to_s}")
self.instance_variable_get("@#{meth.to_s}")
elsif @json.respond_to?(meth)
@json.send(meth)
else
nil
end
end
|
Class Method Details
+ (Object) data_src(json)
25
26
27
|
# File 'backend/app/exporters/models/ead.rb', line 25
def self.data_src(json)
@data_src.new(json)
end
|
+ (Object) from_resource(obj, opts)
71
72
73
|
# File 'backend/app/exporters/models/ead.rb', line 71
def self.from_resource(obj, opts)
self.new(obj, opts)
end
|
Instance Method Details
- (Object) addresslines
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'backend/app/exporters/models/ead.rb', line 113
def addresslines
agent = self.agent_representation
return [] unless agent && agent.agent_contacts[0]
contact = agent.agent_contacts[0]
data = []
(1..3).each do |i|
data << contact["address_#{i}"]
end
line = ""
line += %w(city region).map{|k| contact[k] }.compact.join(', ')
line += " #{contact['post_code']}"
line.strip!
data << line unless line.empty?
%w(telephone email).each do |property|
data << contact[property]
end
data.compact!
data
end
|
- (Object) agent_representation
103
104
105
106
107
108
109
110
|
# File 'backend/app/exporters/models/ead.rb', line 103
def agent_representation
return false unless @repo['agent_representation_id']
agent_id = @repo['agent_representation_id']
json = AgentCorporateEntity.to_jsonmodel(agent_id)
json
end
|
- (Object) creators_and_sources
153
154
155
|
# File 'backend/app/exporters/models/ead.rb', line 153
def creators_and_sources
self.linked_agents.select{|link| ['creator', 'source'].include?(link['role']) }
end
|
- (Object) descrules
141
142
143
144
145
|
# File 'backend/app/exporters/models/ead.rb', line 141
def descrules
return nil unless @descrules || self.finding_aid_description_rules
@descrules ||= I18n.t("enumerations.resource_finding_aid_description_rules.#{self.finding_aid_description_rules}", :default => self.finding_aid_description_rules)
@descrules
end
|
- (Object) digital_objects
158
159
160
161
162
163
164
|
# File 'backend/app/exporters/models/ead.rb', line 158
def digital_objects
if @include_daos
self.instances.select{|inst| inst['digital_object']}.compact.map{|inst| inst['digital_object']['_resolved'] }.compact
else
[]
end
end
|
- (Boolean) include_unpublished?
87
88
89
|
# File 'backend/app/exporters/models/ead.rb', line 87
def include_unpublished?
@include_unpublished
end
|
- (Object) instances_with_containers
148
149
150
|
# File 'backend/app/exporters/models/ead.rb', line 148
def instances_with_containers
self.instances.select{|inst| inst['container']}.compact
end
|
- (Object) mainagencycode
97
98
99
100
|
# File 'backend/app/exporters/models/ead.rb', line 97
def mainagencycode
@mainagencycode ||= repo.country && repo.org_code ? [repo.country, repo.org_code].join('-') : nil
@mainagencycode
end
|
92
93
94
|
# File 'backend/app/exporters/models/ead.rb', line 92
def use_numbered_c_tags?
@use_numbered_c_tags
end
|