Class: CanTango::Config::Engines
- Inherits:
-
Object
- Object
- CanTango::Config::Engines
- Includes:
- Available, Order, Registry::Hash::InstanceMethods, Enumerable, Singleton
- Defined in:
- lib/cantango/config/engines.rb,
lib/cantango/config/engines/order.rb,
lib/cantango/config/engines/available.rb
Defined Under Namespace
Instance Method Summary collapse
- #active?(name) ⇒ Boolean
- #active_list ⇒ Object
- #clear! ⇒ Object
- #each ⇒ Object
-
#register(hash) ⇒ Object
engine registry is a simple hash.
Methods included from Registry::Hash::InstanceMethods
#<<, #[], #[]=, #clean!, #default, #default!, #default=, #registered, #registered?, #registered_names, #registered_value?, #registered_values, #types, #types=, #unregister, #value_methods, #value_types
Methods included from Available
#all, #any?, #available, #available?
Methods included from Order
#clear_order!, #dont_execute, #execute_after, #execute_before, #execute_first, #execute_last, #execution_order, #set_execution_order
Instance Method Details
#active?(name) ⇒ Boolean
31 32 33 |
# File 'lib/cantango/config/engines.rb', line 31 def active? name active.include? name.to_sym end |
#active_list ⇒ Object
35 36 37 |
# File 'lib/cantango/config/engines.rb', line 35 def active_list available.select {|engine| send(engine).on? if respond_to?(engine) } end |
#clear! ⇒ Object
21 22 23 24 25 |
# File 'lib/cantango/config/engines.rb', line 21 def clear! each {|engine| engine.reset! } @registered = nil clear_order! end |
#each ⇒ Object
27 28 29 |
# File 'lib/cantango/config/engines.rb', line 27 def each available.each {|engine| yield send(engine) if respond_to?(engine) } end |
#register(hash) ⇒ Object
engine registry is a simple hash
13 14 15 16 17 18 19 |
# File 'lib/cantango/config/engines.rb', line 13 def register hash hash.each_pair do |name, engine_class| raise "Class must implement the CanTango::Engine API." unless self.class.valid_engine?(engine_class) raise "Name of engine must be a String or Symbol" if !name.kind_of_label? registered[name.to_s] = engine_class end end |