Sha256: c54a4f02447851487e7ceb0ba6586b1f9fc7610cd0767c367d4b51c39be17130
Contents?: true
Size: 1.07 KB
Versions: 77
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Checkoff module Internal # Builds on the standard API representation of an Asana project with some # convenience keys. class ProjectHashes # @param _deps [Hash] def initialize(_deps = {}); end # @param project_obj [Asana::Resources::Project] # @param project [String, Symbol<:not_specified, :my_tasks>] # # @return [Hash] 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 private # @param project_hash [Hash] # @return [void] def unwrap_custom_fields(project_hash) unwrapped_custom_fields = project_hash.fetch('custom_fields', []).group_by do |cf| cf['name'] end.transform_values(&:first) project_hash['unwrapped']['custom_fields'] = unwrapped_custom_fields end end end end
Version data entries
77 entries across 77 versions & 1 rubygems