Class: Record
- Inherits:
-
Object
- Object
- Record
- Defined in:
- public/app/models/record.rb
Direct Known Subclasses
Accession, AgentCorporateEntity, AgentFamily, AgentPerson, ArchivalObject, Classification, Container, DigitalObject, Resource, ResourceOrderedRecords, Subject
Constant Summary collapse
- ABSTRACT =
%w(abstract scopecontent)
Instance Attribute Summary collapse
-
#agents ⇒ Object
readonly
Returns the value of attribute agents.
-
#classifications ⇒ Object
readonly
Returns the value of attribute classifications.
-
#container_display ⇒ Object
readonly
Returns the value of attribute container_display.
-
#container_summary_for_badge ⇒ Object
readonly
Returns the value of attribute container_summary_for_badge.
-
#container_titles_and_uris ⇒ Object
readonly
Returns the value of attribute container_titles_and_uris.
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#dates ⇒ Object
readonly
Returns the value of attribute dates.
-
#display_string ⇒ Object
readonly
Returns the value of attribute display_string.
-
#extents ⇒ Object
readonly
Returns the value of attribute extents.
-
#external_documents ⇒ Object
readonly
Returns the value of attribute external_documents.
-
#full ⇒ Object
readonly
Returns the value of attribute full.
-
#highlights ⇒ Object
Returns the value of attribute highlights.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#lang_materials ⇒ Object
readonly
Returns the value of attribute lang_materials.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#linked_digital_objects ⇒ Object
readonly
Returns the value of attribute linked_digital_objects.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#other_level ⇒ Object
readonly
Returns the value of attribute other_level.
-
#primary_type ⇒ Object
readonly
Returns the value of attribute primary_type.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#repository_information ⇒ Object
readonly
Returns the value of attribute repository_information.
-
#resolved_repository ⇒ Object
readonly
Returns the value of attribute resolved_repository.
-
#resolved_resource ⇒ Object
readonly
Returns the value of attribute resolved_resource.
-
#resolved_top_container ⇒ Object
readonly
Returns the value of attribute resolved_top_container.
-
#subjects ⇒ Object
readonly
Returns the value of attribute subjects.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#[](k) ⇒ Object
-
#apply_highlighting ⇒ Object
-
#dig(*args) ⇒ Object
-
#initialize(solr_result, full = false) ⇒ Record
constructor
A new instance of Record.
-
#note(type) ⇒ Object
-
#parse_full_title(infinite_item = false) ⇒ Object
-
#request_item ⇒ Object
Constructor Details
#initialize(solr_result, full = false) ⇒ Record
Returns a new instance of Record.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'public/app/models/record.rb', line 19 def initialize(solr_result, full = false) @raw = solr_result if solr_result['json'].is_a? Hash @json = solr_result['json'] else @json = ASUtils.json_parse(solr_result['json']) || {} end @full = full @primary_type = raw['primary_type'] @uri = raw['uri'] @identifier = parse_identifier @resolved_resource = parse_resource @level = raw['level'] @other_level = json['other_level'] @display_string = parse_full_title @container_display = parse_container_display @container_summary_for_badge = parse_container_summary_for_badge @container_titles_and_uris = parse_container_display(:include_uri => true) @linked_digital_objects = parse_digital_object_instances @notes = parse_notes @dates = parse_dates @lang_materials = parse_lang_materials @external_documents = parse_external_documents @resolved_repository = parse_repository @resolved_top_container = parse_top_container @repository_information = parse_repository_info @subjects = parse_subjects @classifications = parse_classifications @agents = parse_agents(subjects) @extents = parse_extents end |
Instance Attribute Details
#agents ⇒ Object (readonly)
Returns the value of attribute agents
8 9 10 |
# File 'public/app/models/record.rb', line 8 def agents @agents end |
#classifications ⇒ Object (readonly)
Returns the value of attribute classifications
8 9 10 |
# File 'public/app/models/record.rb', line 8 def classifications @classifications end |
#container_display ⇒ Object (readonly)
Returns the value of attribute container_display
8 9 10 |
# File 'public/app/models/record.rb', line 8 def container_display @container_display end |
#container_summary_for_badge ⇒ Object (readonly)
Returns the value of attribute container_summary_for_badge
8 9 10 |
# File 'public/app/models/record.rb', line 8 def container_summary_for_badge @container_summary_for_badge end |
#container_titles_and_uris ⇒ Object (readonly)
Returns the value of attribute container_titles_and_uris
8 9 10 |
# File 'public/app/models/record.rb', line 8 def container_titles_and_uris @container_titles_and_uris end |
#criteria ⇒ Object
Returns the value of attribute criteria
15 16 17 |
# File 'public/app/models/record.rb', line 15 def criteria @criteria end |
#dates ⇒ Object (readonly)
Returns the value of attribute dates
8 9 10 |
# File 'public/app/models/record.rb', line 8 def dates @dates end |
#display_string ⇒ Object (readonly)
Returns the value of attribute display_string
8 9 10 |
# File 'public/app/models/record.rb', line 8 def display_string @display_string end |
#extents ⇒ Object (readonly)
Returns the value of attribute extents
8 9 10 |
# File 'public/app/models/record.rb', line 8 def extents @extents end |
#external_documents ⇒ Object (readonly)
Returns the value of attribute external_documents
8 9 10 |
# File 'public/app/models/record.rb', line 8 def external_documents @external_documents end |
#full ⇒ Object (readonly)
Returns the value of attribute full
8 9 10 |
# File 'public/app/models/record.rb', line 8 def full @full end |
#highlights ⇒ Object
Returns the value of attribute highlights
15 16 17 |
# File 'public/app/models/record.rb', line 15 def highlights @highlights end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier
8 9 10 |
# File 'public/app/models/record.rb', line 8 def identifier @identifier end |
#json ⇒ Object (readonly)
Returns the value of attribute json
8 9 10 |
# File 'public/app/models/record.rb', line 8 def json @json end |
#lang_materials ⇒ Object (readonly)
Returns the value of attribute lang_materials
8 9 10 |
# File 'public/app/models/record.rb', line 8 def lang_materials @lang_materials end |
#level ⇒ Object (readonly)
Returns the value of attribute level
8 9 10 |
# File 'public/app/models/record.rb', line 8 def level @level end |
#linked_digital_objects ⇒ Object (readonly)
Returns the value of attribute linked_digital_objects
8 9 10 |
# File 'public/app/models/record.rb', line 8 def linked_digital_objects @linked_digital_objects end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes
8 9 10 |
# File 'public/app/models/record.rb', line 8 def notes @notes end |
#other_level ⇒ Object (readonly)
Returns the value of attribute other_level
8 9 10 |
# File 'public/app/models/record.rb', line 8 def other_level @other_level end |
#primary_type ⇒ Object (readonly)
Returns the value of attribute primary_type
8 9 10 |
# File 'public/app/models/record.rb', line 8 def primary_type @primary_type end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw
8 9 10 |
# File 'public/app/models/record.rb', line 8 def raw @raw end |
#repository_information ⇒ Object (readonly)
Returns the value of attribute repository_information
8 9 10 |
# File 'public/app/models/record.rb', line 8 def repository_information @repository_information end |
#resolved_repository ⇒ Object (readonly)
Returns the value of attribute resolved_repository
8 9 10 |
# File 'public/app/models/record.rb', line 8 def resolved_repository @resolved_repository end |
#resolved_resource ⇒ Object (readonly)
Returns the value of attribute resolved_resource
8 9 10 |
# File 'public/app/models/record.rb', line 8 def resolved_resource @resolved_resource end |
#resolved_top_container ⇒ Object (readonly)
Returns the value of attribute resolved_top_container
8 9 10 |
# File 'public/app/models/record.rb', line 8 def resolved_top_container @resolved_top_container end |
#subjects ⇒ Object (readonly)
Returns the value of attribute subjects
8 9 10 |
# File 'public/app/models/record.rb', line 8 def subjects @subjects end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri
8 9 10 |
# File 'public/app/models/record.rb', line 8 def uri @uri end |
Instance Method Details
#[](k) ⇒ Object
78 79 80 81 82 83 84 |
# File 'public/app/models/record.rb', line 78 def [](k) if k == 'json' json else raw[k] end end |
#apply_highlighting ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'public/app/models/record.rb', line 55 def apply_highlighting if highlights.key?('title') && highlights['title'].length == 1 @display_string = highlights['title'][0] end # Exclude any redundant fields below that are not meant to be used in the public intreface. exclude_fields = [ 'title', 'notes', 'summary', 'agents', 'agents_text', 'repository', 'used_within_repository', 'used_within_published_repository', 'classification_uris' ] @highlights = highlights.reject do |key, _| exclude_fields.include?(key) end end |
#dig(*args) ⇒ Object
86 87 88 |
# File 'public/app/models/record.rb', line 86 def dig(*args) json.dig(args) end |
#note(type) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'public/app/models/record.rb', line 90 def note(type) if notes && notes[type] note = notes[type][0].clone for i in 1...notes[type].length note = merge_notes(note, notes[type][i]) end note else {} end end |
#parse_full_title(infinite_item = false) ⇒ Object
108 109 110 111 112 113 |
# File 'public/app/models/record.rb', line 108 def parse_full_title(infinite_item = false) unless infinite_item || json['title_inherited'].blank? || (json['display_string'] || '') == json['title'] return "#{json['title']}, #{json['display_string']}" end return process_mixed_content_title(json['display_string'] || json['title']) end |
#request_item ⇒ Object
102 103 104 105 106 |
# File 'public/app/models/record.rb', line 102 def request_item return unless RequestItem.allow_for_type(resolved_repository.dig('repo_code'), primary_type.intern) build_request_item end |