Class: NavigatorRails::Decorator
- Inherits:
-
Object
- Object
- NavigatorRails::Decorator
- Extended by:
- Contextable
- Includes:
- Singleton
- Defined in:
- lib/navigator_rails/decorator.rb
Instance Attribute Summary
Attributes included from Contextable
Class Method Summary collapse
Instance Method Summary collapse
- #at(params = {}) ⇒ Object
- #for(type) ⇒ Object
-
#initialize ⇒ Decorator
constructor
A new instance of Decorator.
- #register(type, decorator) ⇒ Object
Methods included from Contextable
Constructor Details
#initialize ⇒ Decorator
Returns a new instance of Decorator.
10 11 12 |
# File 'lib/navigator_rails/decorator.rb', line 10 def initialize @decorators = {} end |
Class Method Details
.at(params) ⇒ Object
6 |
# File 'lib/navigator_rails/decorator.rb', line 6 def at params; Decorator.instance.at params; end |
.for(decorator) ⇒ Object
7 |
# File 'lib/navigator_rails/decorator.rb', line 7 def for decorator; Decorator.instance.for decorator; end |
.register(type, decorator) ⇒ Object
8 |
# File 'lib/navigator_rails/decorator.rb', line 8 def register type, decorator; Decorator.instance.register type, decorator; end |
Instance Method Details
#at(params = {}) ⇒ Object
13 14 15 |
# File 'lib/navigator_rails/decorator.rb', line 13 def at params={} return NavigatorRails.config[:decorators][params[:level]-1] if params[:level] end |
#for(type) ⇒ Object
16 17 18 |
# File 'lib/navigator_rails/decorator.rb', line 16 def for type @decorators[type] if @decorators[type] end |
#register(type, decorator) ⇒ Object
19 20 21 |
# File 'lib/navigator_rails/decorator.rb', line 19 def register type, decorator @decorators[type] = decorator end |