Class: FakeRails3Routes::Mapper
- Inherits:
-
Object
- Object
- FakeRails3Routes::Mapper
- Includes:
- Base, HttpHelpers, Resources, Scoping
- Defined in:
- lib/fake_rails3_routes/mapper.rb
Defined Under Namespace
Modules: Base, HttpHelpers, Resources, Scoping Classes: Mapping
Constant Summary collapse
- SEPARATORS =
:nodoc:
%w( / . ? )
- HTTP_METHODS =
:nodoc:
[:get, :head, :post, :put, :delete, :options]
Constants included from Resources
Resources::CANONICAL_ACTIONS, Resources::RESOURCE_OPTIONS, Resources::VALID_ON_OPTIONS
Class Method Summary collapse
- .normalize_name(name) ⇒ Object
-
.normalize_path(path) ⇒ Object
Invokes Rack::Mount::Utils.normalize path and ensure that (:locale) becomes (/:locale) instead of /(:locale).
Instance Method Summary collapse
-
#initialize(set) ⇒ Mapper
constructor
A new instance of Mapper.
Methods included from Resources
#add_route, #collection, #concern, #concerns, #decomposed_match, #match, #member, #namespace, #nested, #new, #resource, #resources, #resources_path_names, #root, #shallow, #shallow?, #using_match_shorthand?
Methods included from Scoping
#constraints, #controller, #defaults, #namespace, #scope
Methods included from HttpHelpers
Methods included from Base
#default_url_options=, #match, #root, #with_default_scope
Constructor Details
#initialize(set) ⇒ Mapper
Returns a new instance of Mapper.
6 7 8 9 |
# File 'lib/fake_rails3_routes/mapper.rb', line 6 def initialize(set) @set = set @scope = { :path_names => { :new => 'new', :edit => 'edit' } } end |
Class Method Details
.normalize_name(name) ⇒ Object
20 21 22 |
# File 'lib/fake_rails3_routes/mapper.rb', line 20 def self.normalize_name(name) normalize_path(name)[1..-1].gsub("/", "_") end |
.normalize_path(path) ⇒ Object
Invokes Rack::Mount::Utils.normalize path and ensure that (:locale) becomes (/:locale) instead of /(:locale). Except for root cases, where the latter is the correct one.
14 15 16 17 18 |
# File 'lib/fake_rails3_routes/mapper.rb', line 14 def self.normalize_path(path) path = Journey::Router::Utils.normalize_path(path) path.gsub!(%r{/(\(+)/?}, '\1/') unless path =~ %r{^/\(+[^)]+\)$} path end |