Sha256: 39c76451ed5046ba84d00be34a101ca7b78fb5dcbdc9a2450b4bfb5b3db186c3
Contents?: true
Size: 1.5 KB
Versions: 5
Compression:
Stored size: 1.5 KB
Contents
module Mack module Rendering module Engine # 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 class Registry include Singleton # Returns all the engines registered with the system. attr_reader :engines def initialize @engines = { :action => [:erubis, :builder, :markaby, :haml], :template => [:erubis, :builder, :markaby, :haml], :partial => [:erubis, :builder, :markaby, :haml], :layout => [:erubis, :markaby, :haml], :xml => [:builder, :erubis, :markaby, :haml] } end # Registers an engine to a type. # # Example: # Mack::Rendering::Engine::Registry.register(:action, :haml) 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 class << self def method_missing(sym, *args) Mack::Rendering::Engine::Registry.instance.send(sym, *args) end end end # Registry end # Engines end # Rendering end # Mack
Version data entries
5 entries across 5 versions & 1 rubygems