Class: Utopia::Controller::Rewrite::Rewriter
- Inherits:
-
Object
- Object
- Utopia::Controller::Rewrite::Rewriter
- Defined in:
- lib/utopia/controller/rewrite.rb
Instance Method Summary collapse
- #apply(context, request, path) ⇒ Object
- #extract_prefix(**arguments, &block) ⇒ Object
-
#initialize ⇒ Rewriter
constructor
A new instance of Rewriter.
- #invoke!(context, request, path) ⇒ Object
Constructor Details
#initialize ⇒ Rewriter
Returns a new instance of Rewriter.
88 89 90 |
# File 'lib/utopia/controller/rewrite.rb', line 88 def initialize @rules = [] end |
Instance Method Details
#apply(context, request, path) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/utopia/controller/rewrite.rb', line 96 def apply(context, request, path) @rules.each do |rule| path = rule.apply(context, request, path) end return path end |
#extract_prefix(**arguments, &block) ⇒ Object
92 93 94 |
# File 'lib/utopia/controller/rewrite.rb', line 92 def extract_prefix(**arguments, &block) @rules << ExtractPrefixRule.new(arguments, block) end |
#invoke!(context, request, path) ⇒ Object
104 105 106 |
# File 'lib/utopia/controller/rewrite.rb', line 104 def invoke!(context, request, path) path.components = apply(context, request, path).components end |