Class: PaperTrailDiff::AssociationDescriptor

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

Overview

One discoverable ActiveRecord association path.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, kind:, target_type:, through: nil, flags: []) ⇒ AssociationDescriptor

: (path: String, kind: Symbol, target_type: String?, ?through: String?, ?flags: Array) -> void

Parameters:

  • path: (String)
  • kind: (Symbol)
  • target_type: (String, nil)
  • through: (String, nil) (defaults to: nil)
  • flags: (Array[Symbol]) (defaults to: [])


15
16
17
18
19
20
21
22
23
# File 'lib/paper_trail_diff/association_discovery.rb', line 15

def initialize(path:, kind:, target_type:, through: nil, flags: [])
  @path = Support.immutable_copy(path)
  @kind = kind
  @target_type = Support.immutable_copy(target_type)
  @through = Support.immutable_copy(through)
  @polymorphic = flags.include?(:polymorphic)
  @cycle = flags.include?(:cycle)
  freeze
end

Instance Attribute Details

#cycleBoolean (readonly)

Signature:

  • bool

Returns:

  • (Boolean)


12
13
14
# File 'lib/paper_trail_diff/association_discovery.rb', line 12

def cycle
  @cycle
end

#kindSymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def kind
  @kind
end

#pathString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def path
  @path
end

#polymorphicBoolean (readonly)

Signature:

  • bool

Returns:

  • (Boolean)


11
12
13
# File 'lib/paper_trail_diff/association_discovery.rb', line 11

def polymorphic
  @polymorphic
end

#target_typeString? (readonly)

Signature:

  • String?

Returns:

  • (String, nil)


9
10
11
# File 'lib/paper_trail_diff/association_discovery.rb', line 9

def target_type
  @target_type
end

#throughString? (readonly)

Signature:

  • String?

Returns:

  • (String, nil)


10
11
12
# File 'lib/paper_trail_diff/association_discovery.rb', line 10

def through
  @through
end

Instance Method Details

#to_hHash[Symbol, untyped]

: () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


26
27
28
29
30
31
32
33
34
35
# File 'lib/paper_trail_diff/association_discovery.rb', line 26

def to_h
  {
    path: path,
    kind: kind,
    target_type: target_type,
    through: through,
    polymorphic: polymorphic,
    cycle: cycle
  }
end