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.
69 70 71 |
# File 'lib/utopia/controller/rewrite.rb', line 69 def initialize @rules = [] end |
Instance Method Details
#apply(context, request, path) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/utopia/controller/rewrite.rb', line 77 def apply(context, request, path) @rules.each do |rule| path = rule.apply(context, request, path) end return path end |
#extract_prefix(**arguments, &block) ⇒ Object
73 74 75 |
# File 'lib/utopia/controller/rewrite.rb', line 73 def extract_prefix(**arguments, &block) @rules << ExtractPrefixRule.new(arguments, block) end |
#invoke!(context, request, path) ⇒ Object
85 86 87 |
# File 'lib/utopia/controller/rewrite.rb', line 85 def invoke!(context, request, path) path.components = apply(context, request, path).components end |