Class: Utopia::Controller::Rewrite::Rewriter

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/controller/rewrite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRewriter

Returns a new instance of Rewriter.



91
92
93
# File 'lib/utopia/controller/rewrite.rb', line 91

def initialize
	@rules = []
end

Instance Attribute Details

#rulesObject (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