Class: ProjectMetadata
- Inherits:
-
Object
- Object
- ProjectMetadata
- Defined in:
- app/models/project_metadata.rb
Constant Summary collapse
- DOI_NOT_MINTED =
"DOI-NOT-MINTED"
Instance Attribute Summary collapse
-
#approval_note ⇒ Object
Returns the value of attribute approval_note.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#created_on ⇒ Object
Returns the value of attribute created_on.
-
#data_manager ⇒ Object
Returns the value of attribute data_manager.
-
#data_sponsor ⇒ Object
Returns the value of attribute data_sponsor.
-
#data_user_read_only ⇒ Object
Returns the value of attribute data_user_read_only.
-
#data_user_read_write ⇒ Object
Returns the value of attribute data_user_read_write.
-
#departments ⇒ Object
Returns the value of attribute departments.
-
#description ⇒ Object
Returns the value of attribute description.
-
#project_directory ⇒ Object
Returns the value of attribute project_directory.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#project_purpose ⇒ Object
Returns the value of attribute project_purpose.
-
#schema_version ⇒ Object
Returns the value of attribute schema_version.
-
#status ⇒ Object
Returns the value of attribute status.
-
#storage_capacity ⇒ Object
Returns the value of attribute storage_capacity.
-
#storage_performance_expectations ⇒ Object
Returns the value of attribute storage_performance_expectations.
-
#submission ⇒ Object
Returns the value of attribute submission.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_by ⇒ Object
Returns the value of attribute updated_by.
-
#updated_on ⇒ Object
Returns the value of attribute updated_on.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ProjectMetadata
constructor
A new instance of ProjectMetadata.
-
#initialize_from_hash(metadata_hash) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize_from_params(params) ⇒ Object
Initializes the object with the values in the params (which is an ActionController::Parameters).
-
#ro_users ⇒ Object
Alias for ‘data_user_read_only`.
-
#rw_users ⇒ Object
Alias for ‘data_user_read_write`.
-
#update_with_params(params, current_user) ⇒ Object
Updates the object with the values in the params (which is an ActionController::Parameters) Notice how we only update values that come in the params and don’t change the values that don’t come as part of the params rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize ⇒ ProjectMetadata
Returns a new instance of ProjectMetadata.
9 10 11 12 13 |
# File 'app/models/project_metadata.rb', line 9 def initialize @departments = [] @data_user_read_only = [] @data_user_read_write = [] end |
Instance Attribute Details
#approval_note ⇒ Object
Returns the value of attribute approval_note.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def approval_note @approval_note end |
#created_by ⇒ Object
Returns the value of attribute created_by.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def created_by @created_by end |
#created_on ⇒ Object
Returns the value of attribute created_on.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def created_on @created_on end |
#data_manager ⇒ Object
Returns the value of attribute data_manager.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def data_manager @data_manager end |
#data_sponsor ⇒ Object
Returns the value of attribute data_sponsor.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def data_sponsor @data_sponsor end |
#data_user_read_only ⇒ Object
Returns the value of attribute data_user_read_only.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def data_user_read_only @data_user_read_only end |
#data_user_read_write ⇒ Object
Returns the value of attribute data_user_read_write.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def data_user_read_write @data_user_read_write end |
#departments ⇒ Object
Returns the value of attribute departments.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def departments @departments end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def description @description end |
#project_directory ⇒ Object
Returns the value of attribute project_directory.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def project_directory @project_directory end |
#project_id ⇒ Object
Returns the value of attribute project_id.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def project_id @project_id end |
#project_purpose ⇒ Object
Returns the value of attribute project_purpose.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def project_purpose @project_purpose end |
#schema_version ⇒ Object
Returns the value of attribute schema_version.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def schema_version @schema_version end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def status @status end |
#storage_capacity ⇒ Object
Returns the value of attribute storage_capacity.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def storage_capacity @storage_capacity end |
#storage_performance_expectations ⇒ Object
Returns the value of attribute storage_performance_expectations.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def storage_performance_expectations @storage_performance_expectations end |
#submission ⇒ Object
Returns the value of attribute submission.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def submission @submission end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def title @title end |
#updated_by ⇒ Object
Returns the value of attribute updated_by.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def updated_by @updated_by end |
#updated_on ⇒ Object
Returns the value of attribute updated_on.
5 6 7 |
# File 'app/models/project_metadata.rb', line 5 def updated_on @updated_on end |
Class Method Details
.new_from_hash(metadata_hash) ⇒ Object
15 16 17 18 19 |
# File 'app/models/project_metadata.rb', line 15 def self.new_from_hash() pm = ProjectMetadata.new pm.initialize_from_hash() pm end |
.new_from_params(metadata_params) ⇒ Object
21 22 23 24 25 |
# File 'app/models/project_metadata.rb', line 21 def self.new_from_params() pm = ProjectMetadata.new pm.initialize_from_params() pm end |
Instance Method Details
#initialize_from_hash(metadata_hash) ⇒ Object
rubocop:disable Metrics/MethodLength
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/project_metadata.rb', line 28 def initialize_from_hash() @title = [:title] @description = [:description] @status = [:status] if [:status] @data_sponsor = [:data_sponsor] @data_manager = [:data_manager] @departments = [:departments] @data_user_read_only = [:data_user_read_only] if [:data_user_read_only] @data_user_read_write = [:data_user_read_write] if [:data_user_read_write] @project_id = [:project_id] || ProjectMetadata::DOI_NOT_MINTED @project_purpose = [:project_purpose] @project_directory = [:project_directory] @storage_capacity = [:storage_capacity] @storage_performance_expectations = [:storage_performance_expectations] @created_by = [:created_by] if [:created_by] @created_on = [:created_on] if [:created_on] @updated_by = [:updated_by] if [:updated_by] @updated_on = [:updated_on] if [:updated_on] set_defaults end |
#initialize_from_params(params) ⇒ Object
Initializes the object with the values in the params (which is an ActionController::Parameters)
54 55 56 57 58 |
# File 'app/models/project_metadata.rb', line 54 def initialize_from_params(params) @data_user_read_only = ro_users_from_params(params) @data_user_read_write = rw_users_from_params(params) initialize_from_hash(params) end |
#ro_users ⇒ Object
Alias for ‘data_user_read_only`
92 93 94 |
# File 'app/models/project_metadata.rb', line 92 def ro_users @data_user_read_only end |
#rw_users ⇒ Object
Alias for ‘data_user_read_write`
97 98 99 |
# File 'app/models/project_metadata.rb', line 97 def rw_users @data_user_read_write end |
#update_with_params(params, current_user) ⇒ Object
Updates the object with the values in the params (which is an ActionController::Parameters) Notice how we only update values that come in the params and don’t change the values that don’t come as part of the params rubocop:disable Metrics/MethodLength
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/project_metadata.rb', line 64 def update_with_params(params, current_user) set_value(params, "title") set_value(params, "description") set_value(params, "status") set_value(params, "data_sponsor") set_value(params, "data_manager") set_value(params, "departments") set_value(params, "project_id") set_value(params, "project_purpose") calculate_project_directory(params) if params["data_user_counter"].present? @data_user_read_only = ro_users_from_params(params) @data_user_read_write = rw_users_from_params(params) end update_storage_capacity(params) update_storage_performance_expectations update_approval_note(params, current_user) @submission = params[:submission] if params[:submission] # Fields that come from the edit form @updated_by = current_user.uid @updated_on = Time.current.in_time_zone("America/New_York").iso8601 end |