Module: Extension::Tasks::Converters::VersionConverter

Defined in:
lib/project_types/extension/tasks/converters/version_converter.rb

Constant Summary collapse

REGISTRATION_ID_FIELD =
"registrationId"
CONTEXT_FIELD =
"context"
LAST_USER_INTERACTION_AT_FIELD =
"lastUserInteractionAt"
LOCATION_FIELD =
"location"
VALIDATION_ERRORS_FIELD =
"validationErrors"

Class Method Summary collapse

Class Method Details

.from_hash(context, hash) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/project_types/extension/tasks/converters/version_converter.rb', line 14

def self.from_hash(context, hash)
  context.abort(context.message("tasks.errors.parse_error")) if hash.nil?

  Models::Version.new(
    registration_id: hash[REGISTRATION_ID_FIELD].to_i,
    context: hash[CONTEXT_FIELD],
    last_user_interaction_at: Time.parse(hash[LAST_USER_INTERACTION_AT_FIELD]),
    location: hash[LOCATION_FIELD],
    validation_errors: Converters::ValidationErrorConverter.from_array(context, hash[VALIDATION_ERRORS_FIELD])
  )
end