Aaron Patterson
1eb6b4a679
pull up path normalization.
...
Eventually I want to pull up AST generation so that we don't have to add
it to the `conditions` hash.
2015-08-14 10:39:32 -07:00
Aaron Patterson
95a5d177cc
build_path
doesn't need the path variable anymore
...
It just constructs a Path::Pattern object with the AST that it already
has
2015-08-13 15:44:15 -07:00
Aaron Patterson
947ebe9a6d
remove Strexp
...
This was a useless object. We can just directly construct a
Path::Pattern object without a Strexp object.
2015-08-13 15:42:46 -07:00
Aaron Patterson
4868692687
pass anchor directly to Pattern
...
the caller already has it, there is no reason to pack it in to an object
and just throw that object away.
2015-08-13 15:16:25 -07:00
Aaron Patterson
36f26fd47e
we already have access to the AST, so just use it
2015-08-13 15:03:20 -07:00
Aaron Patterson
b3d73e789c
remove default arguments that aren't used
...
we always pass all parameters, so there is no reason to provide default
arguments.
2015-08-13 14:19:58 -07:00
Aaron Patterson
45d594fa53
pull up options_constrants extraction
2015-08-13 14:15:04 -07:00
Aaron Patterson
b778f6348b
remove as
...
the caller already has access to `as`, so we can stop passing it around.
2015-08-13 14:04:02 -07:00
Aaron Patterson
e38a456faf
remove anchor from mapping
...
the same value that is extracted from the options hash earlier is
returned, so we don't need to pass it in in the first place. The caller
already has the data, so stop passing it around.
2015-08-13 13:58:16 -07:00
Aaron Patterson
aef421ed9d
pull anchor
extraction up
...
this way we don't have to mutate the options hash so far away from where
the user passed it in
2015-08-13 13:55:03 -07:00
Aaron Patterson
33dc653466
raise if anchor
is passed to scope
...
The `anchor` parameter [is overridden](b4b4a611d0/actionpack/lib/action_dispatch/routing/mapper.rb (L1528)
) unless it
is directly passed to `match`, so setting it in a scope must be a
mistake.
2015-08-13 13:41:03 -07:00
Aaron Patterson
ba7602b881
remove the add_request_method
method
...
I didn't like this method because it mutates the parameters. Now that
the method is so small, just push it up to `initialize`
2015-08-12 17:24:23 -07:00
Aaron Patterson
a4f7809472
remove side effects in normalize_defaults
...
now the `@defaults` variable doesn't need to be set before calling
`normalize_defaults`
2015-08-12 17:10:44 -07:00
Aaron Patterson
3e3e23f048
remove unnecessary deletes
...
These three options are stored in the `scope` chain outside of the
options hash. If they are in the options hash, then someone passed them
in to `match` and they don't really do anything. So lets remove the
code.
2015-08-12 17:04:32 -07:00
Aaron Patterson
3955688440
pull format
out of the options hash
...
remove `format` from the options hash in the scope chain so that we
don't need to remove it later
2015-08-12 16:54:35 -07:00
Aaron Patterson
ec895189e4
pull formatted
up the stack
...
this reduces the number of times we have to mutate the options hash.
2015-08-12 16:54:35 -07:00
Aaron Patterson
d61e3c79dc
add a regression test for scoped format
params
...
This just ensures that `format` is applied to things inside the scope
2015-08-12 16:54:35 -07:00
Rafael Mendonça França
7d4ad74ce5
Merge pull request #21214 from rodzyn/fewer_objects_and_refactoring
...
Fewer objects and refactoring
2015-08-12 20:15:37 -03:00
Marcin Olichwirowicz
fc22cb88ed
Simplify code
...
Since we are always responding with an array and using `any?`, we don't
need to check if an array is empty
2015-08-13 01:00:49 +02:00
Marcin Olichwirowicz
0c15b85d5d
Avoid unnecessary MatchData objects
2015-08-13 00:56:29 +02:00
Aaron Patterson
2a05a72e6a
store via
outside the options hash
...
Now we don't have to manually remove this from the options hash since
the scope stores it outside of "options"
2015-08-12 15:54:24 -07:00
Aaron Patterson
f514c9c04a
don't mutate the caller's variables
...
Remove the `options` reader from `Resource` because nobody needs to see
that hash. Also remove mutations on the options hash in
`apply_common_behavior_for` because leaving the side effects in that
method makes it difficult to understand what is going on in the caller.
2015-08-12 15:50:14 -07:00
Aaron Patterson
33d20ea184
store :only
and :except
outside the normal options hash
...
these two keys have a different merge strategy, and they also just get
removed from the options hash later in the code. If we store them in a
separate place, then we don't need to remove them later
2015-08-12 15:30:43 -07:00
Aaron Patterson
e2735b2b32
add a regression test for adding arbitrary keys to scope
2015-08-12 15:17:21 -07:00
Aaron Patterson
1c94317539
add a method to Scope
for getting mapping options
...
Eventually we don't want to expose the "options" hash from scope, only
read values from it. Lets start by adding a reader method.
2015-08-12 14:30:54 -07:00
Aaron Patterson
58117fadae
pull via checking up to via extraction
...
now we don't need to construct a Mapping object just to get an
ArgumentError if there is no `via` parameter provided.
2015-08-12 14:30:53 -07:00
Aaron Patterson
b46c67fb47
pull via
all the way out of add_route
2015-08-12 14:30:53 -07:00
Aaron Patterson
b106dddfaf
fix via handling when it's in a scope
2015-08-12 14:30:53 -07:00
Aaron Patterson
4c641c6e36
add a test for adding "via" using scope
2015-08-12 14:30:53 -07:00
Aaron Patterson
b59ff24207
pull via
extraction up
...
We're going to try pulling this up further, and check `via` validity
sooner. This way we don't have to do a bunch of processing on `options`
hashes only to find out that the route is incorrect
2015-08-12 14:30:53 -07:00
Aaron Patterson
f88c68a819
simplify split_constraints
...
If we do the Regexp verification in a second method, then the
`split_constraints` method gets much easier.
2015-08-12 14:30:53 -07:00
Aaron Patterson
c10d7d1690
remove side effects from normalize_format
2015-08-12 14:30:53 -07:00
Aaron Patterson
b9a622f817
switch === to case / when
2015-08-12 14:30:52 -07:00
Aaron Patterson
463339c4bb
make split_constraints
more functional.
...
I don't want `split_constraints` to mutate any instance variables. That
way it's easier to move the method around and understand what it does
(it has no side effects)
2015-08-12 14:30:52 -07:00
Aaron Patterson
3042b71a7a
make constraints
more functional
...
I don't want to rely on mutating ivars. This gives me more freedom when
refactoring
2015-08-12 14:30:52 -07:00
Aaron Patterson
cbf1617015
only call split_constraints
once
2015-08-11 18:23:25 -07:00
Aaron Patterson
3420849f85
only do is_a? checks on options_constraints
once
...
we don't need to do it so many times.
2015-08-11 18:17:05 -07:00
Aaron Patterson
ea4da199b7
Mapping instances don't need scope
anymore
2015-08-11 18:10:41 -07:00
Aaron Patterson
175280ccb5
pull scope[:constraints] up
...
Now we only need to call `split_constraints` possibly twice!
2015-08-11 18:06:54 -07:00
Aaron Patterson
0988ad0fa7
pull :format up a little bit
...
apparently `format` can also come from the scope options, so we need to
extract it there too.
2015-08-11 18:06:53 -07:00
Sean Griffin
e69364bc2d
Merge pull request #21203 from denniss/issue-21199
...
Authorization scheme should be case insensitive. Fixes #21199
2015-08-11 17:25:00 -06:00
Aaron Patterson
97d7dc48d6
pull to
up
...
this way we don't have to insert / delete it from the options hash so
many times.
2015-08-11 16:16:09 -07:00
Aaron Patterson
c25d1707b9
push scope access up for modules
...
eventually we'll remove the need to access `scope` inside the Mapping
object.
2015-08-11 16:16:09 -07:00
Dennis Suratna
dec2f52fa4
Authorization scheme should be case insensitive. Fixes #21199
2015-08-11 15:59:44 -07:00
Aaron Patterson
41e7923cd4
path is never nil
2015-08-11 14:50:15 -07:00
Aaron Patterson
763dd50a76
split options hash and pass values down
...
`using_match_shorthand?` doesn't need to know that an options hash
exists. Also use this opportunity to make the boolean logic a little
more sane
2015-08-11 14:49:19 -07:00
Aaron Patterson
0c3f8e3f02
pull option duping up
2015-08-11 14:49:19 -07:00
Aaron Patterson
1a830cbd83
split paths by type
...
this simplifies the "downstream" logic since we know we'll only be
dealing with one particular type
2015-08-11 14:49:19 -07:00
Aaron Patterson
7df7c707ab
one fewer hash mutation
2015-08-11 14:49:19 -07:00
Aaron Patterson
5935e4c882
push option decomposition up a bit more
...
I think we can find the original place where `action` is added to the
options hash now.
2015-08-11 14:49:19 -07:00