Module: Safrano::Transitions::GetNextTrans::ByLongestMatchDyn

Included in:
EntityBase::Transitions
Defined in:
lib/odata/transition.rb

Overview

same as ByLongestMatch but use the getter method allowed_transitions instead of directly @allowed_transitions

Instance Method Summary collapse

Instance Method Details

#get_next_transresult(path_remain) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/odata/transition.rb', line 50

def get_next_transresult(path_remain)
  # current url-parsing context
  # has  ambiguous next match and we need to find longest match
  # example: current context is "the top level service" and we have
  # entity types Race and RaceType

  match_len = -1
  tres_next = nil

  allowed_transitions.each { |t|
    if (res = t.longer_match(path_remain, match_len))
      tres_next = res
      match_len = tres_next.match_length
    end
  }
  tres_next
end