Class: Munge::Conglomerate::Router
- Inherits:
-
Object
- Object
- Munge::Conglomerate::Router
- Defined in:
- lib/munge/conglomerate/router.rb,
lib/munge/conglomerate/router/itemish.rb
Defined Under Namespace
Classes: Itemish
Instance Method Summary collapse
- #filepath(item) ⇒ Object
-
#initialize(processor:) ⇒ Router
constructor
A new instance of Router.
- #register(router) ⇒ Object
- #route(item) ⇒ Object
Constructor Details
#initialize(processor:) ⇒ Router
Returns a new instance of Router.
4 5 6 7 |
# File 'lib/munge/conglomerate/router.rb', line 4 def initialize(processor:) @registries = { route: [], filepath: [] } @processor = processor end |
Instance Method Details
#filepath(item) ⇒ Object
25 26 27 28 29 |
# File 'lib/munge/conglomerate/router.rb', line 25 def filepath(item) initial_route = route(item) path = route_mapper(item, :filepath, initial_route) Util::Path.ensure_relpath(path) end |
#register(router) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/munge/conglomerate/router.rb', line 9 def register(router) case router.type when :route @registries[:route].push(router) when :filepath @registries[:filepath].push(router) else raise Error::InvalidRouterError, router.type end end |
#route(item) ⇒ Object
20 21 22 23 |
# File 'lib/munge/conglomerate/router.rb', line 20 def route(item) path = route_mapper(item, :route) Util::Path.ensure_abspath(path) end |