Class: Utopia::Controller::Rewrite::ExtractPrefixRule
- Defined in:
- lib/utopia/controller/rewrite.rb
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
- #apply(context, request, path) ⇒ Object
- #freeze ⇒ Object
-
#initialize(arguments, block) ⇒ ExtractPrefixRule
constructor
A new instance of ExtractPrefixRule.
Methods inherited from Rule
Constructor Details
#initialize(arguments, block) ⇒ ExtractPrefixRule
Returns a new instance of ExtractPrefixRule.
63 64 65 66 67 |
# File 'lib/utopia/controller/rewrite.rb', line 63 def initialize(arguments, block) @matcher = Path::Matcher.new(arguments) super end |
Instance Method Details
#apply(context, request, path) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/utopia/controller/rewrite.rb', line 75 def apply(context, request, path) if match_data = @matcher.match(path) apply_match_to_context(match_data, context) if @block context.instance_exec(request, path, match_data, &@block) end return match_data.post_match else return path end end |
#freeze ⇒ Object
69 70 71 72 73 |
# File 'lib/utopia/controller/rewrite.rb', line 69 def freeze @matcher.freeze super end |