Class: FormResourceDecorator
- Inherits:
-
Object
- Object
- FormResourceDecorator
- Defined in:
- app/decorators/form_resource_decorator.rb
Constant Summary collapse
- SKIPPED_ROLES =
["DISTRIBUTOR", "FUNDER", "HOSTING_INSTITUTION", "REGISTRATION_AGENCY", "REGISTRATION_AUTHORITY", "RESEARCH GROUP"].freeze
- PPPL_FUNDER_NAME =
"United States Department of Energy"
- PPPL_FUNDER_ROR =
"https://ror.org/01bj3aw27"
- PPPL_FUNDER_AWARD_NUMBER =
"DE-AC02-09CH11466"
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Instance Method Summary collapse
- #contributor_types ⇒ Object
- #creators ⇒ Object
- #doi_mutable? ⇒ Boolean
- #funders ⇒ Object
- #individual_contributors ⇒ Object
-
#initialize(work, current_user) ⇒ FormResourceDecorator
constructor
A new instance of FormResourceDecorator.
- #organizational_contributors ⇒ Object
- #related_objects ⇒ Object
Constructor Details
#initialize(work, current_user) ⇒ FormResourceDecorator
Returns a new instance of FormResourceDecorator.
10 11 12 13 14 |
# File 'app/decorators/form_resource_decorator.rb', line 10 def initialize(work, current_user) @resource = work.resource @work = work @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
3 4 5 |
# File 'app/decorators/form_resource_decorator.rb', line 3 def current_user @current_user end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'app/decorators/form_resource_decorator.rb', line 3 def resource @resource end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
3 4 5 |
# File 'app/decorators/form_resource_decorator.rb', line 3 def work @work end |
Instance Method Details
#contributor_types ⇒ Object
29 30 31 32 |
# File 'app/decorators/form_resource_decorator.rb', line 29 def contributor_types @contributor_types ||= Datacite::Mapping::ContributorType.to_a.reject { |role| SKIPPED_ROLES.include? role.key.to_s } @contributor_types end |
#creators ⇒ Object
38 39 40 |
# File 'app/decorators/form_resource_decorator.rb', line 38 def creators item_or_nil_array(resource.creators) end |
#doi_mutable? ⇒ Boolean
46 47 48 49 50 |
# File 'app/decorators/form_resource_decorator.rb', line 46 def doi_mutable? return true unless !@work.nil? && @work.persisted? !@work.approved? end |
#funders ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/decorators/form_resource_decorator.rb', line 16 def funders # @funders probably null for some reason @funders ||= begin empty_row = if pppl? && resource.funders.empty? PDCMetadata::Funder.new(PPPL_FUNDER_ROR, PPPL_FUNDER_NAME, PPPL_FUNDER_AWARD_NUMBER, nil) end resource.funders + [empty_row] end end |
#individual_contributors ⇒ Object
25 26 27 |
# File 'app/decorators/form_resource_decorator.rb', line 25 def individual_contributors item_or_nil_array(resource.individual_contributors) end |
#organizational_contributors ⇒ Object
42 43 44 |
# File 'app/decorators/form_resource_decorator.rb', line 42 def organizational_contributors resource.organizational_contributors + [nil] end |
#related_objects ⇒ Object
34 35 36 |
# File 'app/decorators/form_resource_decorator.rb', line 34 def item_or_nil_array(resource.) end |