Class: Platformer::Composer
- Inherits:
-
Object
- Object
- Platformer::Composer
- Defined in:
- lib/platformer/composer.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ClassDoesNotUseDSLComposeError
Class Method Summary collapse
- .for_each(klass, dsl_name, &block) ⇒ Object
-
.for_each_child_class(klass, &block) ⇒ Object
when provided with a class which has DSLCompose added to it, such as ApplicationModel, this method will execute the provided block once for every child class of the provided class.
Class Method Details
.for_each(klass, dsl_name, &block) ⇒ Object
27 28 29 |
# File 'lib/platformer/composer.rb', line 27 def self.for_each klass, dsl_name, &block # todo end |
.for_each_child_class(klass, &block) ⇒ Object
when provided with a class which has DSLCompose added to it, such as ApplicationModel, this method will execute the provided block once for every child class of the provided class. A common use of this method would be to find all classes of a particular type (such as models or callback definitions) and dynamically create something for each of them
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/platformer/composer.rb', line 14 def self.for_each_child_class klass, &block unless klass.respond_to? :dsls raise ClassDoesNotUseDSLCompose end if block klass.dsls.executions_by_class.each do |k, dsl| yield k end else warn "no block provided" end end |