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
- #call(context, request, path) ⇒ Object
- #extract_prefix(**arguments, &block) ⇒ Object
-
#initialize ⇒ Rewriter
constructor
A new instance of Rewriter.
Constructor Details
#initialize ⇒ Rewriter
Returns a new instance of Rewriter.
85 86 87 |
# File 'lib/utopia/controller/rewrite.rb', line 85 def initialize @rules = [] end |
Instance Method Details
#apply(context, request, path) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/utopia/controller/rewrite.rb', line 93 def apply(context, request, path) @rules.each do |rule| path = rule.apply(context, request, path) end return path end |
#call(context, request, path) ⇒ Object
101 102 103 |
# File 'lib/utopia/controller/rewrite.rb', line 101 def call(context, request, path) path.components = apply(context, request, path).components end |
#extract_prefix(**arguments, &block) ⇒ Object
89 90 91 |
# File 'lib/utopia/controller/rewrite.rb', line 89 def extract_prefix(**arguments, &block) @rules << ExtractPrefixRule.new(arguments, block) end |