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

Conversation

jrgriffiniii
Copy link
Contributor

Resolves #20 and #7 by addressing the following:

  • Refactoring metadata within PlumSchema into Schema::* Modules
  • Adds explicitly defined "suppressed" attributes for decorated Valkyrie Resources

module Plum
##
# Defines the attributes migrated from Hyrax core
module Hyrax
Copy link
Member

Choose a reason for hiding this comment

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

I am wary of naming any of our modules or classes "Hyrax" — mostly for symbolic reasons and to avoid confusion if/when Hyrax support for Valkyrie is undertaken.

I also think it would be nice to split up the terms by source vocabulary: many of these are from DC/DCTerms or MARC Relators.

def self.attributes
[
# Used for a license,
:license,
Copy link
Member

Choose a reason for hiding this comment

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

As with the comment above, breaking these out by source would be nice.

module Plum
##
# Defines the attributes local to Plum
module Local
Copy link
Member

Choose a reason for hiding this comment

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

Same as above: breaking these out by source would be nice, since some of these properties are our own local properties, but some (alternative, identifier, etc.) are DC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, I misunderstood this from within #7 - I can address this as well.


included do
Common.attributes.each do |field|
attribute field
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to avoid this boilerplate code in each schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my primary struggle with this PR, I'll definitely see about this immediately.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine if it's not possible — or we could make a separate ticket for looking into that later so it doesn't block this work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, it is likely to continue to block this work, as I would likely need to abandon any (simple) approach using Modules. Within the scope of included, I do not believe that I can easily reference the Module being mixed into the Class. From what I could determine, this is not a limitation of ActiveSupport::Concern:

https://gist.github.com/jrgriffiniii/8cf9ab64d4ecaff44a2f59284d23ba85

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

You could always make them not modules - add a method like apply_schema to Valhalla::Resource (or via a module I guess) and each schema be a class with an interface that apply_schema can utilize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, something similar was what I was considering for #80 , but I was wary of further blocking this issue.

@@ -1,5 +1,25 @@
# 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

@jrgriffiniii jrgriffiniii force-pushed the issues-20-jrgriffiniii-add-fields-view-sr-mvw branch 4 times, most recently from 96fc69a to b2a39ed Compare August 8, 2017 18:32
@jrgriffiniii jrgriffiniii changed the title [WIP] Refactors the PlumSchema into Schema Modules Refactors the PlumSchema into Schema Modules Aug 8, 2017
@jrgriffiniii jrgriffiniii changed the title Refactors the PlumSchema into Schema Modules [WIP] Refactors the PlumSchema into Schema Modules Aug 8, 2017
@jrgriffiniii jrgriffiniii force-pushed the issues-20-jrgriffiniii-add-fields-view-sr-mvw branch from b2a39ed to 6f35eb6 Compare August 8, 2017 18:52
@jrgriffiniii jrgriffiniii changed the title [WIP] Refactors the PlumSchema into Schema Modules Refactors the PlumSchema into Schema Modules Aug 8, 2017
…e Schema:: Modules; Adds explicitly defined "suppressed" fields for decorated Valkyrie Resources

Migrating the refactored Schema Modules into the ImportedMetadata Class

Addressing styling rules and updating the RuboCops for the Schema Modules

Restructuring the attributes based upon their sources (where possible)

Tracking the new schema Modules

Excluding the Schema Modules from the coverage analysis

Extending the test suites for the schema Modules; Extending the test for the ScannedResource View displayed attributes

Resolving styling issues

Removing extraneous legacy attributes from being suppressed

Removing the unneeded Schema::Schema Module
@jrgriffiniii jrgriffiniii force-pushed the issues-20-jrgriffiniii-add-fields-view-sr-mvw branch from 6f35eb6 to 2c34528 Compare August 8, 2017 20:05
@escowles escowles merged commit 163dead into master Aug 8, 2017
@escowles escowles deleted the issues-20-jrgriffiniii-add-fields-view-sr-mvw branch August 8, 2017 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants