Class: PaperTrailDiff::ValueChange

Inherits:
Object
  • Object
show all
Defined in:
lib/paper_trail_diff/value_objects.rb,
sig/generated/paper_trail_diff/value_objects.rbs

Overview

A directional change between two structured values.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:) ⇒ ValueChange

: (from: untyped, to: untyped) -> void

Parameters:

  • from: (Object)
  • to: (Object)


11
12
13
14
15
# File 'lib/paper_trail_diff/value_objects.rb', line 11

def initialize(from:, to:)
  @from = Support.immutable_copy(from)
  @to = Support.immutable_copy(to)
  freeze
end

Instance Attribute Details

#fromObject (readonly)

Signature:

  • untyped

Returns:

  • (Object)


7
8
9
# File 'lib/paper_trail_diff/value_objects.rb', line 7

def from
  @from
end

#toObject (readonly)

Signature:

  • untyped

Returns:

  • (Object)


8
9
10
# File 'lib/paper_trail_diff/value_objects.rb', line 8

def to
  @to
end

Instance Method Details

#to_hHash[Symbol, untyped]

: () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


18
19
20
# File 'lib/paper_trail_diff/value_objects.rb', line 18

def to_h
  { from: Support.serialize(from), to: Support.serialize(to) }
end