disconnect options and scope from the blocks
method
This commit is contained in:
parent
e975b7d04e
commit
496e25aab7
@ -79,6 +79,7 @@ def initialize(scope, path, options)
|
|||||||
|
|
||||||
formatted = options.delete :format
|
formatted = options.delete :format
|
||||||
via = Array(options.delete(:via) { [] })
|
via = Array(options.delete(:via) { [] })
|
||||||
|
@blocks = blocks(options[:constraints], scope[:blocks])
|
||||||
|
|
||||||
path = normalize_path! path, formatted
|
path = normalize_path! path, formatted
|
||||||
ast = path_ast path
|
ast = path_ast path
|
||||||
@ -87,14 +88,14 @@ def initialize(scope, path, options)
|
|||||||
|
|
||||||
|
|
||||||
constraints = constraints(options[:constraints], scope[:constraints])
|
constraints = constraints(options[:constraints], scope[:constraints])
|
||||||
normalize_requirements!(path_params, formatted, constraints)
|
|
||||||
|
|
||||||
|
normalize_requirements!(path_params, formatted, constraints)
|
||||||
normalize_conditions!(path_params, path, ast, via, constraints)
|
normalize_conditions!(path_params, path, ast, via, constraints)
|
||||||
normalize_defaults!(formatted)
|
normalize_defaults!(formatted)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_route
|
def to_route
|
||||||
[ app, conditions, requirements, defaults, as, anchor ]
|
[ app(@blocks), conditions, requirements, defaults, as, anchor ]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -232,7 +233,7 @@ def normalize_conditions!(path_params, path, ast, via, constraints)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def app
|
def app(blocks)
|
||||||
return to if Redirect === to
|
return to if Redirect === to
|
||||||
|
|
||||||
if to.respond_to?(:call)
|
if to.respond_to?(:call)
|
||||||
@ -303,11 +304,11 @@ def translate_controller(controller)
|
|||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
def blocks
|
def blocks(options_constraints, scope_blocks)
|
||||||
if options[:constraints].present? && !options[:constraints].is_a?(Hash)
|
if options_constraints.present? && !options_constraints.is_a?(Hash)
|
||||||
[options[:constraints]]
|
[options_constraints]
|
||||||
else
|
else
|
||||||
scope[:blocks] || []
|
scope_blocks || []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user