Sha256: e150e4928ffd27076c0c2f7fc2a517db96c894e152a1bf468b55c92a3783b38a

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

class NodeMutation::Result
  attr_accessor :file_path, :new_source
  attr_reader :actions

  def initialize(affected:, conflicted:)
    @affected = affected
    @conflicted = conflicted
    @actions = []
  end

  def affected?
    @affected
  end

  def conflicted?
    @conflicted
  end

  def actions=(actions)
    @actions =
      actions.map { |action|
        NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code, action.actions)
      }
  end

  def to_json(*args)
    data = { affected: affected?, conflicted: conflicted? }
    data[:new_source] = new_source if new_source
    data[:actions] = actions unless actions.empty?
    data.to_json(*args)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
node_mutation-1.21.1 lib/node_mutation/result.rb