Module: MetadataPresenter::BranchDestinations

Included in:
Coordinates, Grid
Defined in:
app/models/metadata_presenter/branch_destinations.rb

Instance Method Summary collapse

Instance Method Details

#exiting_destinations_from_branch(branch) ⇒ Object

The frontend requires that expressions of type ‘or’ get there own line and arrow. ‘and’ expression types continue to be grouped together. Return the UUIDs of the destinations exiting a branch and allow duplicates if the expression type is an ‘or’.



7
8
9
10
11
12
13
14
15
16
# File 'app/models/metadata_presenter/branch_destinations.rb', line 7

def exiting_destinations_from_branch(branch)
  destination_uuids = branch.conditionals.map do |conditional|
    if conditional.type == 'or'
      conditional.expressions.map { |_| conditional.next }
    else
      conditional.next
    end
  end
  destination_uuids.flatten.push(branch.default_next)
end

#has_or_conditionals?(branch) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/metadata_presenter/branch_destinations.rb', line 18

def has_or_conditionals?(branch)
  branch.conditionals.any? { |c| c.type == 'or' }
end