Class: NodeMutation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/node_mutation/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(affected:, conflicted:) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
# File 'lib/node_mutation/result.rb', line 7

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

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



4
5
6
# File 'lib/node_mutation/result.rb', line 4

def actions
  @actions
end

#file_pathObject

Returns the value of attribute file_path.



4
5
6
# File 'lib/node_mutation/result.rb', line 4

def file_path
  @file_path
end

#new_sourceObject

Returns the value of attribute new_source.



4
5
6
# File 'lib/node_mutation/result.rb', line 4

def new_source
  @new_source
end

Instance Method Details

#affected?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/node_mutation/result.rb', line 13

def affected?
  @affected
end

#conflicted?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/node_mutation/result.rb', line 17

def conflicted?
  @conflicted
end

#to_json(*args) ⇒ Object



21
22
23
24
25
26
# File 'lib/node_mutation/result.rb', line 21

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