Skip to content

Commit

Permalink
Merge pull request #79 from pulibrary/issues-20-jrgriffiniii-add-fiel…
Browse files Browse the repository at this point in the history
…ds-view-sr-mvw

Refactors the PlumSchema into Schema Modules
  • Loading branch information
escowles committed Aug 8, 2017
2 parents 34628a0 + 2c34528 commit 163dead
Show file tree
Hide file tree
Showing 39 changed files with 1,180 additions and 353 deletions.
7 changes: 5 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ Metrics/BlockLength:
Metrics/MethodLength:
Exclude:
- 'db/migrate/**/*'
- 'app/models/plum_schema.rb'
- 'app/models/schema/dublin_core.rb'
- 'app/models/schema/marc_relators.rb'
- 'app/models/schema/plum/local.rb'
- 'spec/services/manifest_builder_spec.rb'
Metrics/ModuleLength:
Exclude:
- 'app/models/plum_schema.rb'
- 'app/models/schema/dublin_core.rb'
- 'app/models/schema/marc_relators.rb'
RSpec/MultipleExpectations:
Enabled: false
RSpec/ExampleLength:
Expand Down
5 changes: 3 additions & 2 deletions app/decorators/application_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true
class ApplicationDecorator < Draper::Decorator
class_attribute :display_attributes
class_attribute :suppressed_attributes, :display_attributes
self.suppressed_attributes = []
self.display_attributes = []
delegate_all

def display_attributes
Hash[
self.class.display_attributes.map do |attribute|
(self.class.display_attributes - self.class.suppressed_attributes).map do |attribute|
[attribute, Array.wrap(self.[](attribute))]
end
]
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/scanned_resource_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class ScannedResourceDecorator < Valkyrie::ResourceDecorator
self.display_attributes = [:imported_author, :internal_resource, :created_at, :updated_at, :rendered_rights_statement, :member_of_collections, :rendered_holding_location]
self.display_attributes += Schema::Common.attributes + [:member_of_collections, :rendered_holding_location]
delegate :query_service, to: :metadata_adapter
delegate :author, to: :primary_imported_metadata, prefix: :imported

Expand Down
15 changes: 15 additions & 0 deletions app/decorators/valkyrie/resource_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# frozen_string_literal: true
class Valkyrie::ResourceDecorator < ApplicationDecorator
self.suppressed_attributes = [
:description,
:rights_statement,
:holding_location,
:title,
:depositor,
:source_metadata_identifier,
:source_metadata,
:nav_date,
:pdf_type,
:ocr_language,
:keyword,
:source_jsonld,
:sort_title
]
self.display_attributes = [:internal_resource, :created_at, :updated_at]

def created_at
Expand Down
2 changes: 1 addition & 1 deletion app/models/imported_metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
class ImportedMetadata < Valkyrie::Resource
include PlumSchema
include Schema::Plum
end
320 changes: 0 additions & 320 deletions app/models/plum_schema.rb

This file was deleted.

Loading

0 comments on commit 163dead

Please sign in to comment.