Module: Machined::Initializable::ClassMethods

Defined in:
lib/machined/initializable.rb

Instance Method Summary collapse

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, options = {}, &block)
  initializer = Initializer.new(name, block)

  if after = options[:after]
    initializers.insert initializer_index(after) + 1, initializer
  elsif before = options[:before]
    initializers.insert initializer_index(before), initializer
  else
    initializers << initializer
  end
end

#initializersObject

Returns an array of the initializers for this class.



28
29
30
# File 'lib/machined/initializable.rb', line 28

def initializers
  @initializers ||= []
end