Class: Rory::Initializers
- Inherits:
-
Object
- Object
- Rory::Initializers
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/rory/initializers.rb
Defined Under Namespace
Classes: Initializer
Instance Attribute Summary collapse
-
#initializers ⇒ Object
Returns the value of attribute initializers.
Instance Method Summary collapse
- #add(name, &block) ⇒ Object
- #delete(target) ⇒ Object
-
#initialize {|_self| ... } ⇒ Initializers
constructor
A new instance of Initializers.
- #insert(index, name, &block) ⇒ Object (also: #insert_before)
- #insert_after(index, name, &block) ⇒ Object
- #run(app) ⇒ Object
- #unshift(name, &block) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Initializers
Returns a new instance of Initializers.
31 32 33 34 |
# File 'lib/rory/initializers.rb', line 31 def initialize @initializers = [] yield(self) if block_given? end |
Instance Attribute Details
#initializers ⇒ Object
Returns the value of attribute initializers.
28 29 30 |
# File 'lib/rory/initializers.rb', line 28 def initializers @initializers end |
Instance Method Details
#add(name, &block) ⇒ Object
56 57 58 |
# File 'lib/rory/initializers.rb', line 56 def add(name, &block) initializers.push(build_initializer(name, block)) end |
#delete(target) ⇒ Object
52 53 54 |
# File 'lib/rory/initializers.rb', line 52 def delete(target) initializers.delete_if { |m| m.name == target } end |
#insert(index, name, &block) ⇒ Object Also known as: insert_before
40 41 42 43 |
# File 'lib/rory/initializers.rb', line 40 def insert(index, name, &block) index = assert_index(index, :before) initializers.insert(index, build_initializer(name, block)) end |
#insert_after(index, name, &block) ⇒ Object
47 48 49 50 |
# File 'lib/rory/initializers.rb', line 47 def insert_after(index, name, &block) index = assert_index(index, :after) insert(index + 1, name, &block) end |
#run(app) ⇒ Object
60 61 62 |
# File 'lib/rory/initializers.rb', line 60 def run(app) initializers.map{|i| i.call(app)} end |
#unshift(name, &block) ⇒ Object
36 37 38 |
# File 'lib/rory/initializers.rb', line 36 def unshift(name, &block) initializers.unshift(build_initializer(name, block)) end |