app/lib/chief.rb
# Given project data, return it with the proposed changeset applied.
# Note: This should probably be class-level
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
Given project data, return it with the proposed changeset applied.
Given project data return it with the proposed changeset applied .
def apply_changes(project, changes)
    changes.each do |key, data|
      next unless ALLOWED_FIELDS.include?(key)
      next unless update_value?(project, key, data)
      project[key] = data[:value]
      next unless key.to_s.end_with?('_status') && data.key?(:explanation)
      justification_key =
        (key.to_s.chomp('_status') + '_justification').to_sym
      if project.attribute_present?(justification_key)
        unless project[justification_key].end_with?(data[:explanation])
          project[justification_key] =
            project[justification_key] + ' ' + data[:explanation]
        end
      else
        project[justification_key] = data[:explanation]
      end
    end
  end
def apply_changes ( project , changes ) changes . each do | key , data | next unless ALLOWED_FIELDS . include? ( key ) next unless update_value? ( project , key , data ) project [ key ] = data [ :value ] next unless key . to_s . end_with? ( '_status' ) && data . key? ( :explanation ) justification_key = ( key . to_s . chomp ( '_status' ) + '_justification' ) . to_sym if project . attribute_present? ( justification_key ) unless project [ justification_key ] . end_with? ( data [ :explanation ] ) project [ justification_key ] = project [ justification_key ] + ' ' + data [ :explanation ] end else project [ justification_key ] = data [ :explanation ] end end end
Given project data, return it with the proposed changeset applied.
Given project data return it with the proposed changeset applied .
# Store change: # Now add the explanation, if we can.
project
<not_specific>
changes
<not_specific>