Class: ActionDispatch::Routing::Mapper::Mapping
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper::Mapping
- Defined in:
- lib/action_dispatch/routing/mapper.rb
Overview
:nodoc:
Constant Summary collapse
- ANCHOR_CHARACTERS_REGEX =
%r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
- OPTIONAL_FORMAT_REGEX =
%r{(?:\(\.:format\)+|\.:format|/)\Z}
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Returns the value of attribute anchor.
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#default_action ⇒ Object
readonly
Returns the value of attribute default_action.
-
#default_controller ⇒ Object
readonly
Returns the value of attribute default_controller.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scope, set, path, defaults, as, options) ⇒ Mapping
constructor
A new instance of Mapping.
- #to_route ⇒ Object
Constructor Details
#initialize(scope, set, path, defaults, as, options) ⇒ Mapping
Returns a new instance of Mapping.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/action_dispatch/routing/mapper.rb', line 82 def initialize(scope, set, path, defaults, as, ) @requirements, @conditions = {}, {} @defaults = defaults @set = set @to = .delete :to @default_controller = .delete(:controller) || scope[:controller] @default_action = .delete(:action) || scope[:action] @as = as @anchor = .delete :anchor formatted = .delete :format via = Array(.delete(:via) { [] }) = .delete :constraints path = normalize_path! path, formatted ast = path_ast path path_params = path_params ast = (, formatted, path_params, ast, scope[:module]) split_constraints(path_params, scope[:constraints]) if scope[:constraints] constraints = constraints(, path_params) split_constraints path_params, constraints @blocks = blocks(, scope[:blocks]) if .is_a?(Hash) split_constraints path_params, .each do |key, default| if URL_OPTIONS.include?(key) && (String === default || Integer === default) @defaults[key] ||= default end end end normalize_format!(formatted) @conditions[:path_info] = path @conditions[:parsed_path_info] = ast add_request_method(via, @conditions) normalize_defaults!() end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Returns the value of attribute anchor.
66 67 68 |
# File 'lib/action_dispatch/routing/mapper.rb', line 66 def anchor @anchor end |
#as ⇒ Object (readonly)
Returns the value of attribute as.
66 67 68 |
# File 'lib/action_dispatch/routing/mapper.rb', line 66 def as @as end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def conditions @conditions end |
#default_action ⇒ Object (readonly)
Returns the value of attribute default_action.
66 67 68 |
# File 'lib/action_dispatch/routing/mapper.rb', line 66 def default_action @default_action end |
#default_controller ⇒ Object (readonly)
Returns the value of attribute default_controller.
66 67 68 |
# File 'lib/action_dispatch/routing/mapper.rb', line 66 def default_controller @default_controller end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def defaults @defaults end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def requirements @requirements end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
66 67 68 |
# File 'lib/action_dispatch/routing/mapper.rb', line 66 def to @to end |
Class Method Details
.build(scope, set, path, as, options) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/action_dispatch/routing/mapper.rb', line 68 def self.build(scope, set, path, as, ) = scope[:options].merge() if scope[:options] .delete :only .delete :except .delete :shallow_path .delete :shallow_prefix .delete :shallow defaults = (scope[:defaults] || {}).merge .delete(:defaults) || {} new scope, set, path, defaults, as, end |
Instance Method Details
#to_route ⇒ Object
129 130 131 |
# File 'lib/action_dispatch/routing/mapper.rb', line 129 def to_route [ app(@blocks), conditions, requirements, defaults, as, anchor ] end |