Sha256: cb98a2959be2d900d0b4e1917c4a2d0dfb730e2d583a0a2685f57df3054952dd

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

class NodeMutation::Result
  attr_accessor :file_path

  def initialize(options)
    @options = options
  end

  def affected?
    @options[:affected]
  end

  def conflicted?
    @options[:conflicted]
  end

  def actions
    @options[:actions]
  end

  def new_source
    @options[:new_source]
  end

  def to_json(*args)
    to_hash.to_json(*args)
  end

  def to_hash
    hash = { file_path: file_path }
    @options.each do |key, value|
      if key == :actions
        hash[:actions] = value.map { |action| { start: action.start, end: action.end, new_code: action.new_code } }
      else
        hash[key] = value
      end
    end
    hash
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
node_mutation-1.12.0 lib/node_mutation/result.rb
node_mutation-1.11.0 lib/node_mutation/result.rb
node_mutation-1.10.1 lib/node_mutation/result.rb