Class: Checkoff::Internal::ProjectHashes
- Inherits:
-
Object
- Object
- Checkoff::Internal::ProjectHashes
- Defined in:
- lib/checkoff/internal/project_hashes.rb,
sig/checkoff.rbs
Overview
Builds on the standard API representation of an Asana project with some convenience keys.
Instance Method Summary collapse
-
#initialize(_deps = {}) ⇒ ProjectHashes
constructor
@param
_deps. -
#project_to_h(project_obj, project: :not_specified) ⇒ ::Hash[untyped, untyped]
sord warn - Asana::Resources::Project wasn't able to be resolved to a constant in this project sord warn - ""unwrapped"" does not appear to be a type sord warn - "Hash{"custom_fields" => Hash{String =" does not appear to be a type The two custom_fields entries below hold the same records: the top-level array is what Asana returns, and unwrapped re-keys those records by name.
-
#unwrap_custom_fields(project_hash) ⇒ void
@param
project_hash.
Constructor Details
#initialize(_deps = {}) ⇒ ProjectHashes
@param _deps
10 |
# File 'lib/checkoff/internal/project_hashes.rb', line 10 def initialize(_deps = {}); end |
Instance Method Details
#project_to_h(project_obj, project: :not_specified) ⇒ ::Hash[untyped, untyped]
sord warn - Asana::Resources::Project wasn't able to be resolved to a constant in this project sord warn - ""unwrapped"" does not appear to be a type sord warn - "Hash{"custom_fields" => Hash{String =" does not appear to be a type The two custom_fields entries below hold the same records: the top-level array is what Asana returns, and unwrapped re-keys those records by name.
@param project_obj
@param project — - a String is a project name
38 39 40 41 42 43 44 |
# File 'lib/checkoff/internal/project_hashes.rb', line 38 def project_to_h(project_obj, project: :not_specified) project = project_obj.name if project == :not_specified project_hash = { **project_obj.to_h, 'project' => project } project_hash['unwrapped'] = {} unwrap_custom_fields(project_hash) project_hash end |
#unwrap_custom_fields(project_hash) ⇒ void
This method returns an undefined value.
@param project_hash
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/checkoff/internal/project_hashes.rb', line 50 def unwrap_custom_fields(project_hash) # @type [Array<Hash{String => Object}>,nil] custom_fields = project_hash['custom_fields'] return if custom_fields.nil? unwrapped_custom_fields = custom_fields.group_by do |cf| cf['name'] end.transform_values(&:first) project_hash['unwrapped']['custom_fields'] = unwrapped_custom_fields end |