Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/route_translator/extensions/mapper.rb
Instance Method Summary collapse
-
#add_route(action, controller, options, _path, to, via, formatted, anchor, options_constraints) ⇒ Object
rubocop:disable Lint/UnderscorePrefixedVariableName, Metrics/PerceivedComplexity.
- #localized ⇒ Object
Instance Method Details
#add_route(action, controller, options, _path, to, via, formatted, anchor, options_constraints) ⇒ Object
rubocop:disable Lint/UnderscorePrefixedVariableName, Metrics/PerceivedComplexity
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/route_translator/extensions/mapper.rb', line 15 def add_route(action, controller, , _path, to, via, formatted, anchor, ) # :nodoc: return super unless @localized path = path_for_action(action, _path) raise ArgumentError, 'path is required' if path.blank? action = action.to_s default_action = .delete(:action) || @scope[:action] if %r{^[\w\-\/]+$}.match?(action) default_action ||= action.tr('-', '_') unless action.include?('/') else action = nil end as = if .fetch(:as, true) name_for_action(.delete(:as), action) else .delete(:as) end path = Mapping.normalize_path URI::DEFAULT_PARSER.escape(path), formatted ast = Journey::Parser.parse path mapping = Mapping.build(@scope, @set, ast, controller, default_action, to, via, formatted, , anchor, ) @set.add_localized_route(mapping, as, anchor, @scope, path, controller, default_action, to, via, formatted, , ) end |
#localized ⇒ Object
8 9 10 11 12 |
# File 'lib/route_translator/extensions/mapper.rb', line 8 def localized @localized = true yield @localized = false end |