Skip to content

Commit

Permalink
Switch to named captures for route regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Jul 30, 2018
1 parent 1acf979 commit f61bbe9
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/actors_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class ActorsGate < Api::Action
REGEX = %r{\A/features/(.*)/actors/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/actors/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand Down Expand Up @@ -36,7 +36,7 @@ def ensure_valid_params
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/boolean_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class BooleanGate < Api::Action
REGEX = %r{\A/features/(.*)/boolean/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/boolean/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -28,7 +28,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/clear_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class ClearFeature < Api::Action
REGEX = %r{\A/features/(.*)/clear/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/clear/?\Z}
match { |request| request.path_info =~ REGEX }

def delete
Expand All @@ -20,7 +20,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class Feature < Api::Action
REGEX = %r{\A/features/(.*)/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/?\Z}
match { |request| request.path_info =~ REGEX }

def get
Expand All @@ -25,7 +25,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/groups_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class GroupsGate < Api::Action
REGEX = %r{\A/features/(.*)/groups/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/groups/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand Down Expand Up @@ -50,7 +50,7 @@ def disallow_unregistered_groups?
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/percentage_of_actors_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class PercentageOfActorsGate < Api::Action
REGEX = %r{\A/features/(.*)/percentage_of_actors/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/percentage_of_actors/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -32,7 +32,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/api/v1/actions/percentage_of_time_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module V1
module Actions
class PercentageOfTimeGate < Api::Action
REGEX = %r{\A/features/(.*)/percentage_of_time/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/percentage_of_time/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -33,7 +33,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/actors_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Flipper
module UI
module Actions
class ActorsGate < UI::Action
REGEX = %r{\A/features/(.*)/actors/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/actors/?\Z}
match { |request| request.path_info =~ REGEX }

def get
Expand Down Expand Up @@ -47,7 +47,7 @@ def post
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/boolean_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Flipper
module UI
module Actions
class BooleanGate < UI::Action
REGEX = %r{\A/features/(.*)/boolean/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/boolean/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -26,7 +26,7 @@ def post
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Flipper
module UI
module Actions
class Feature < UI::Action
REGEX = %r{\A/features/(.*)\Z}
REGEX = %r{\A/features/(?<feature_name>.*)\Z}
match { |request| request.path_info =~ REGEX }

def get
Expand Down Expand Up @@ -40,7 +40,7 @@ def delete
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/groups_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Flipper
module UI
module Actions
class GroupsGate < UI::Action
REGEX = %r{\A/features/(.*)/groups/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/groups/?\Z}
match { |request| request.path_info =~ REGEX }

def get
Expand Down Expand Up @@ -44,7 +44,7 @@ def post
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/percentage_of_actors_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Flipper
module UI
module Actions
class PercentageOfActorsGate < UI::Action
REGEX = %r{\A/features/(.*)/percentage_of_actors/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/percentage_of_actors/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -27,7 +27,7 @@ def post
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flipper/ui/actions/percentage_of_time_gate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Flipper
module UI
module Actions
class PercentageOfTimeGate < UI::Action
REGEX = %r{\A/features/(.*)/percentage_of_time/?\Z}
REGEX = %r{\A/features/(?<feature_name>.*)/percentage_of_time/?\Z}
match { |request| request.path_info =~ REGEX }

def post
Expand All @@ -27,7 +27,7 @@ def post
def feature_name
@feature_name ||= begin
match = request.path_info.match(REGEX)
match ? match[1] : nil
match ? match[:feature_name] : nil
end
end
end
Expand Down

0 comments on commit f61bbe9

Please sign in to comment.