Class: RailsFlowMap::FlowEdge

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_flow_map/models/flow_edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, type:, label: nil, attributes: {}) ⇒ FlowEdge

Returns a new instance of FlowEdge.



5
6
7
8
9
10
11
# File 'lib/rails_flow_map/models/flow_edge.rb', line 5

def initialize(from:, to:, type:, label: nil, attributes: {})
  @from = from
  @to = to
  @type = type
  @label = label
  @attributes = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/rails_flow_map/models/flow_edge.rb', line 3

def attributes
  @attributes
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/rails_flow_map/models/flow_edge.rb', line 3

def from
  @from
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/rails_flow_map/models/flow_edge.rb', line 3

def label
  @label
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/rails_flow_map/models/flow_edge.rb', line 3

def to
  @to
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/rails_flow_map/models/flow_edge.rb', line 3

def type
  @type
end

Instance Method Details

#action_flow?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rails_flow_map/models/flow_edge.rb', line 17

def action_flow?
  type == :action_flow
end

#association?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rails_flow_map/models/flow_edge.rb', line 13

def association?
  [:belongs_to, :has_one, :has_many, :has_and_belongs_to_many].include?(type)
end

#to_hObject



21
22
23
24
25
26
27
28
29
# File 'lib/rails_flow_map/models/flow_edge.rb', line 21

def to_h
  {
    from: from,
    to: to,
    type: type,
    label: label,
    attributes: attributes
  }
end