Class: Edison::Router
- Inherits:
-
Object
- Object
- Edison::Router
- Defined in:
- lib/edison.rb
Instance Attribute Summary collapse
-
#static ⇒ Object
readonly
Returns the value of attribute static.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Instance Method Summary collapse
- #copy(url) ⇒ Object
-
#initialize ⇒ Router
constructor
A new instance of Router.
- #url(url, view = nil, data = {}, &b) ⇒ Object
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
92 93 94 95 |
# File 'lib/edison.rb', line 92 def initialize @urls = [] @static = [] end |
Instance Attribute Details
#static ⇒ Object (readonly)
Returns the value of attribute static.
91 92 93 |
# File 'lib/edison.rb', line 91 def static @static end |
#urls ⇒ Object (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 |