Class: Utopia::Controller::Rewrite::Rewriter
- Inherits:
-
Object
- Object
- Utopia::Controller::Rewrite::Rewriter
- Defined in:
- lib/utopia/controller/rewrite.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
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.
91 92 93 |
# File 'lib/utopia/controller/rewrite.rb', line 91 def initialize @rules = [] end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
95 96 97 |
# File 'lib/utopia/controller/rewrite.rb', line 95 def rules @rules end |
Instance Method Details
#apply(context, request, path) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/utopia/controller/rewrite.rb', line 101 def apply(context, request, path) @rules.each do |rule| path = rule.apply(context, request, path) end return path end |
#call(context, request, path) ⇒ Object
109 110 111 |
# File 'lib/utopia/controller/rewrite.rb', line 109 def call(context, request, path) path.components = apply(context, request, path).components end |
#extract_prefix(**arguments, &block) ⇒ Object
97 98 99 |
# File 'lib/utopia/controller/rewrite.rb', line 97 def extract_prefix(**arguments, &block) @rules << ExtractPrefixRule.new(arguments, block) end |