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(**patterns, &block) ⇒ Object
-
#initialize ⇒ Rewriter
constructor
A new instance of Rewriter.
Constructor Details
#initialize ⇒ Rewriter
Returns a new instance of Rewriter.
74 75 76 |
# File 'lib/utopia/controller/rewrite.rb', line 74 def initialize @rules = [] end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
78 79 80 |
# File 'lib/utopia/controller/rewrite.rb', line 78 def rules @rules end |
Instance Method Details
#apply(context, request, path) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/utopia/controller/rewrite.rb', line 84 def apply(context, request, path) @rules.each do |rule| path = rule.apply(context, request, path) end return path end |
#call(context, request, path) ⇒ Object
92 93 94 |
# File 'lib/utopia/controller/rewrite.rb', line 92 def call(context, request, path) path.components = apply(context, request, path).components end |
#extract_prefix(**patterns, &block) ⇒ Object
80 81 82 |
# File 'lib/utopia/controller/rewrite.rb', line 80 def extract_prefix(**patterns, &block) @rules << ExtractPrefixRule.new(patterns, block) end |