Class: Mack::Rendering::Engine::Registry
- Includes:
- Singleton
- Defined in:
- lib/mack/rendering/engine/registry.rb
Overview
A registry used to store which Mack::Rendering::Type objects can use which Mack::Rendering::Engine objects.
Example:
Mack::Rendering::Engine::Registry.register(:bar, :sass)
render(:bar, "my_file") will now get run through Mack::Rendering::Type::Bar and Mack::Rendering::Engine::Sass
Instance Attribute Summary collapse
-
#engines ⇒ Object
readonly
Returns all the engines registered with the system.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#register(type, engine) ⇒ Object
Registers an engine to a type.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
15 16 17 18 19 20 21 22 23 |
# File 'lib/mack/rendering/engine/registry.rb', line 15 def initialize @engines = { :action => [:erubis, :builder], :template => [:erubis, :builder], :partial => [:erubis, :builder], :layout => [:erubis], :xml => [:builder, :erubis] } end |
Instance Attribute Details
#engines ⇒ Object (readonly)
Returns all the engines registered with the system.
13 14 15 |
# File 'lib/mack/rendering/engine/registry.rb', line 13 def engines @engines end |
Class Method Details
Instance Method Details
#register(type, engine) ⇒ Object
Registers an engine to a type.
Example: Mack::Rendering::Engine::Registry.register(:action, :haml)
29 30 31 32 33 34 35 36 |
# File 'lib/mack/rendering/engine/registry.rb', line 29 def register(type, engine) type = type.to_sym if self.engines.has_key?(type) self.engines[type].insert(0, engine) else self.engines[type] = [engine] end end |