Class: Crossroads::Router
- Inherits:
-
Object
- Object
- Crossroads::Router
- Includes:
- Clearwater::Component
- Defined in:
- lib/crossroads/router.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}, component: nil, render: nil, &block) ⇒ Router
constructor
A new instance of Router.
- #render ⇒ Object
Constructor Details
#initialize(attributes = {}, component: nil, render: nil, &block) ⇒ Router
Returns a new instance of Router.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/crossroads/router.rb', line 5 def initialize(attributes = {}, component: nil, render: nil, &block) @render = ->(params) { component.new(params) } if component @render = render if render @render = block if block location = attributes.delete(:location) || $$.window.location.pathname @attributes = attributes # @attributes[:key] ||= location @@locations = [ location ] @@matched = [false] end |
Class Method Details
.locations ⇒ Object
22 23 24 |
# File 'lib/crossroads/router.rb', line 22 def self.locations return @@locations end |
.matched ⇒ Object
26 27 28 |
# File 'lib/crossroads/router.rb', line 26 def self.matched return @@matched end |
Instance Method Details
#render ⇒ Object
18 19 20 |
# File 'lib/crossroads/router.rb', line 18 def render div(@attributes, [@render.call]) end |