Class: Edison::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/edison.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouter

Returns a new instance of Router.



92
93
94
95
# File 'lib/edison.rb', line 92

def initialize
	@urls = []
	@static = []
end

Instance Attribute Details

#staticObject (readonly)

Returns the value of attribute static.



91
92
93
# File 'lib/edison.rb', line 91

def static
  @static
end

#urlsObject (readonly)

Returns the value of attribute urls.



91
92
93
# File 'lib/edison.rb', line 91

def urls
  @urls
end

Instance Method Details

#copy(url) ⇒ Object



107
108
109
# File 'lib/edison.rb', line 107

def copy(url)
	@static << url
end

#url(url, view = nil, data = {}, &b) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/edison.rb', line 96

def url(url, view=nil, data={}, &b)
	if b and view and data
		raise Exception, "Please pass data or block, not both!"
	end
	if b
		data = @urls.find { |(u, _, _)| u == url}[2]
		b.call(data)
	else
		@urls << [url, view, Hashie::Mash.new(data)]
	end
end