Class: Odin::Types::DiffChange

Inherits:
Object
  • Object
show all
Defined in:
lib/odin/types/diff.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, old_value:, new_value:, old_modifiers: nil, new_modifiers: nil) ⇒ DiffChange

Returns a new instance of DiffChange.



29
30
31
32
33
34
35
36
# File 'lib/odin/types/diff.rb', line 29

def initialize(path:, old_value:, new_value:, old_modifiers: nil, new_modifiers: nil)
  @path = path.freeze
  @old_value = old_value
  @new_value = new_value
  @old_modifiers = old_modifiers
  @new_modifiers = new_modifiers
  freeze
end

Instance Attribute Details

#new_modifiersObject (readonly)

Returns the value of attribute new_modifiers.



27
28
29
# File 'lib/odin/types/diff.rb', line 27

def new_modifiers
  @new_modifiers
end

#new_valueObject (readonly)

Returns the value of attribute new_value.



27
28
29
# File 'lib/odin/types/diff.rb', line 27

def new_value
  @new_value
end

#old_modifiersObject (readonly)

Returns the value of attribute old_modifiers.



27
28
29
# File 'lib/odin/types/diff.rb', line 27

def old_modifiers
  @old_modifiers
end

#old_valueObject (readonly)

Returns the value of attribute old_value.



27
28
29
# File 'lib/odin/types/diff.rb', line 27

def old_value
  @old_value
end

#pathObject (readonly)

Returns the value of attribute path.



27
28
29
# File 'lib/odin/types/diff.rb', line 27

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



38
39
40
41
42
# File 'lib/odin/types/diff.rb', line 38

def ==(other)
  other.is_a?(DiffChange) && path == other.path &&
    old_value == other.old_value && new_value == other.new_value &&
    old_modifiers == other.old_modifiers && new_modifiers == other.new_modifiers
end

#hashObject



45
46
47
# File 'lib/odin/types/diff.rb', line 45

def hash
  [path, old_value, new_value, old_modifiers, new_modifiers].hash
end