Class: Rails::Initializable::Initializer
- Defined in:
- railties/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
- #belongs_to?(group) ⇒ Boolean
- #bind(context) ⇒ Object
-
#initialize(name, context, options, &block) ⇒ Initializer
constructor
A new instance of Initializer.
- #run(*args) ⇒ Object
Constructor Details
permalink #initialize(name, context, options, &block) ⇒ Initializer
Returns a new instance of Initializer.
12 13 14 15 |
# File 'railties/lib/rails/initializable.rb', line 12 def initialize(name, context, , &block) [:group] ||= :default @name, @context, @options, @block = name, context, , block end |
Instance Attribute Details
Instance Method Details
permalink #after ⇒ Object
[View source]
21 22 23 |
# File 'railties/lib/rails/initializable.rb', line 21 def after @options[:after] end |
permalink #before ⇒ Object
[View source]
17 18 19 |
# File 'railties/lib/rails/initializable.rb', line 17 def before @options[:before] end |
permalink #belongs_to?(group) ⇒ Boolean
25 26 27 |
# File 'railties/lib/rails/initializable.rb', line 25 def belongs_to?(group) @options[:group] == group || @options[:group] == :all end |
permalink #bind(context) ⇒ Object
[View source]
33 34 35 36 |
# File 'railties/lib/rails/initializable.rb', line 33 def bind(context) return self if @context Initializer.new(@name, context, @options, &block) end |
permalink #run(*args) ⇒ Object
[View source]
29 30 31 |
# File 'railties/lib/rails/initializable.rb', line 29 def run(*args) @context.instance_exec(*args, &block) end |