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}
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.
81 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 |
# File 'lib/action_dispatch/routing/mapper.rb', line 81 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 || Fixnum === 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.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def anchor @anchor end |
#as ⇒ Object (readonly)
Returns the value of attribute as.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def as @as end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
64 65 66 |
# File 'lib/action_dispatch/routing/mapper.rb', line 64 def conditions @conditions end |
#default_action ⇒ Object (readonly)
Returns the value of attribute default_action.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def default_action @default_action end |
#default_controller ⇒ Object (readonly)
Returns the value of attribute default_controller.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def default_controller @default_controller end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
64 65 66 |
# File 'lib/action_dispatch/routing/mapper.rb', line 64 def defaults @defaults end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
64 65 66 |
# File 'lib/action_dispatch/routing/mapper.rb', line 64 def requirements @requirements end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
65 66 67 |
# File 'lib/action_dispatch/routing/mapper.rb', line 65 def to @to end |
Class Method Details
.build(scope, set, path, as, options) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/action_dispatch/routing/mapper.rb', line 67 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
128 129 130 |
# File 'lib/action_dispatch/routing/mapper.rb', line 128 def to_route [ app(@blocks), conditions, requirements, defaults, as, anchor ] end |