Class: ActionDispatch::Journey::Formatter::MissingRoute

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/journey/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constraints, missing_keys, unmatched_keys, routes, name) ⇒ MissingRoute

Returns a new instance of MissingRoute.



37
38
39
40
41
42
43
# File 'lib/action_dispatch/journey/formatter.rb', line 37

def initialize(constraints, missing_keys, unmatched_keys, routes, name)
  @constraints = constraints
  @missing_keys = missing_keys
  @unmatched_keys = unmatched_keys
  @routes = routes
  @name = name
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints.



35
36
37
# File 'lib/action_dispatch/journey/formatter.rb', line 35

def constraints
  @constraints
end

#missing_keysObject (readonly)

Returns the value of attribute missing_keys.



35
36
37
# File 'lib/action_dispatch/journey/formatter.rb', line 35

def missing_keys
  @missing_keys
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/action_dispatch/journey/formatter.rb', line 35

def name
  @name
end

#routesObject (readonly)

Returns the value of attribute routes.



35
36
37
# File 'lib/action_dispatch/journey/formatter.rb', line 35

def routes
  @routes
end

#unmatched_keysObject (readonly)

Returns the value of attribute unmatched_keys.



35
36
37
# File 'lib/action_dispatch/journey/formatter.rb', line 35

def unmatched_keys
  @unmatched_keys
end

Instance Method Details

#messageObject



53
54
55
56
57
58
# File 'lib/action_dispatch/journey/formatter.rb', line 53

def message
  message = +"No route matches #{Hash[constraints.sort_by { |k, v| k.to_s }].inspect}"
  message << ", missing required keys: #{missing_keys.sort.inspect}" if missing_keys && !missing_keys.empty?
  message << ", possible unmatched constraints: #{unmatched_keys.sort.inspect}" if unmatched_keys && !unmatched_keys.empty?
  message
end

#paramsObject



49
50
51
# File 'lib/action_dispatch/journey/formatter.rb', line 49

def params
  path("unknown")
end

#path(method_name) ⇒ Object



45
46
47
# File 'lib/action_dispatch/journey/formatter.rb', line 45

def path(method_name)
  raise ActionController::UrlGenerationError.new(message, routes, name, method_name)
end