Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors the PlumSchema into Schema Modules #79

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what's going on here, since at first blush these look like attributes we'd want to display. Is this related to moving the imported attributes to a nested resource, so these get suppressed on the parent resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will document this in the code base for clarity. This an attempt to structure the following View logic from Plum:

https://github.com/pulibrary/plum/blob/master/app/views/hyrax/base/_attributes.html.erb#L8
https://github.com/pulibrary/plum/blob/master/app/schemas/plum_schema.rb#L302

: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