Class: AASMMermaid::Transition

Inherits:
Object
  • Object
show all
Defined in:
lib/aasm_mermaid/transition.rb

Overview

Represents a diagram transition row

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, event_name:) ⇒ Transition

Returns a new instance of Transition.

Parameters:

  • from (String, Symbol)
    • from transition name

  • to (String, Symbol)
    • to transition name

  • event_name (String, Symbol)
    • transition event name



12
13
14
15
16
# File 'lib/aasm_mermaid/transition.rb', line 12

def initialize(from:, to:, event_name:)
  self.from = from
  self.to = to
  self.event_name = event_name
end

Instance Attribute Details

#event_nameObject

Returns the value of attribute event_name.



7
8
9
# File 'lib/aasm_mermaid/transition.rb', line 7

def event_name
  @event_name
end

#fromObject

Returns the value of attribute from.



7
8
9
# File 'lib/aasm_mermaid/transition.rb', line 7

def from
  @from
end

#toObject

Returns the value of attribute to.



7
8
9
# File 'lib/aasm_mermaid/transition.rb', line 7

def to
  @to
end

Instance Method Details

#==(other) ⇒ true, false

Returns true if given objet is equal, false otherwise.

Returns:

  • (true, false)

    true if given objet is equal, false otherwise



19
20
21
# File 'lib/aasm_mermaid/transition.rb', line 19

def ==(other)
  from.to_s == other.from.to_s && to.to_s == other.to.to_s && event_name == other.event_name
end

#to_diagram_stringString

Returns mermaid diagram string.

Returns:

  • (String)

    mermaid diagram string



24
25
26
# File 'lib/aasm_mermaid/transition.rb', line 24

def to_diagram_string
  "  #{from} --> #{to} : #{event_name}"
end