Class: Utopia::Controller::Rewrite::Rule

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

Direct Known Subclasses

ExtractPrefixRule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, block) ⇒ Rule

Returns a new instance of Rule.



35
36
37
38
39
40
# File 'lib/utopia/controller/rewrite.rb', line 35

def initialize(arguments, block)
	@arguments = arguments
	@block = block
	
	self.freeze
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



49
50
51
# File 'lib/utopia/controller/rewrite.rb', line 49

def arguments
  @arguments
end

#blockObject (readonly)

Returns the value of attribute block.



50
51
52
# File 'lib/utopia/controller/rewrite.rb', line 50

def block
  @block
end

Instance Method Details

#apply_match_to_context(match_data, context) ⇒ Object



52
53
54
55
56
# File 'lib/utopia/controller/rewrite.rb', line 52

def apply_match_to_context(match_data, context)
	match_data.names.each do |name|
		context.instance_variable_set("@#{name}", match_data[name])
	end
end

#freezeObject



42
43
44
45
46
47
# File 'lib/utopia/controller/rewrite.rb', line 42

def freeze
	@arguments.freeze
	@block.freeze
	
	super
end