Class: Rails::Initializable::Initializer
- Inherits:
-
Object
- Object
- Rails::Initializable::Initializer
- Defined in:
- lib/rails/initializable.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #after ⇒ Object
- #before ⇒ Object
- #bind(context) ⇒ Object
-
#initialize(name, context, options, &block) ⇒ Initializer
constructor
A new instance of Initializer.
- #run(*args) ⇒ Object
Constructor Details
#initialize(name, context, options, &block) ⇒ Initializer
Returns a new instance of Initializer.
12 13 14 |
# File 'lib/rails/initializable.rb', line 12 def initialize(name, context, , &block) @name, @context, @options, @block = name, context, , block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
10 11 12 |
# File 'lib/rails/initializable.rb', line 10 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/rails/initializable.rb', line 10 def name @name end |
Instance Method Details
#after ⇒ Object
20 21 22 |
# File 'lib/rails/initializable.rb', line 20 def after @options[:after] end |
#before ⇒ Object
16 17 18 |
# File 'lib/rails/initializable.rb', line 16 def before @options[:before] end |
#bind(context) ⇒ Object
28 29 30 31 |
# File 'lib/rails/initializable.rb', line 28 def bind(context) return self if @context Initializer.new(@name, context, @options, &block) end |
#run(*args) ⇒ Object
24 25 26 |
# File 'lib/rails/initializable.rb', line 24 def run(*args) @context.instance_exec(*args, &block) end |