Method: Jets::Router::Scope#full_prefix

Defined in:
lib/jets/router/scope.rb

#full_prefixObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/jets/router/scope.rb', line 31

def full_prefix
  items = walk_parents do |current, i, result|
    prefix = current.options[:prefix]
    next unless prefix

    case current.from
    when :resources
      variable = prefix.to_s.split('/').last
      variable = ":#{variable.singularize}_id"
      result.unshift(variable)
      result.unshift(prefix)
    else # resource, namespace or general scope
      result.unshift(prefix)
    end
  end

  items.empty? ? nil : items.join('/')
end