Module: Machined::Initializable::ClassMethods
- Defined in:
- lib/machined/initializable.rb
Instance Method Summary collapse
-
#initializer(name, options = {}, &block) ⇒ Object
Creates a new initializer with the given name.
-
#initializers ⇒ Object
Returns an array of the initializers for this class.
Instance Method Details
#initializer(name, options = {}, &block) ⇒ Object
Creates a new initializer with the given name. You can optionally pace initializers before or after other initializers using the ‘:before` and `:after` options. Otherwise the initializer is appended to the of the list.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/machined/initializable.rb', line 37 def initializer(name, = {}, &block) initializer = Initializer.new(name, block) if after = [:after] initializers.insert initializer_index(after) + 1, initializer elsif before = [:before] initializers.insert initializer_index(before), initializer else initializers << initializer end end |
#initializers ⇒ Object
Returns an array of the initializers for this class.
28 29 30 |
# File 'lib/machined/initializable.rb', line 28 def initializers @initializers ||= [] end |