123456789_123456789_123456789_123456789_123456789_

Class: Rails::Initializable::Initializer

Relationships & Source Files
Inherits: Object
Defined in: railties/lib/rails/initializable.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, context, before:, after:, group: nil, &block) ⇒ Initializer

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 14

def initialize(name, context, before:, after:, group: nil, &block)
  @group = group || :default
  @name, @before, @after, @context, @block = name, before, after, context, block
end

Instance Attribute Details

#after (readonly)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 12

attr_reader :name, :block, :before, :after

#before (readonly)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 12

attr_reader :name, :block, :before, :after

#block (readonly)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 12

attr_reader :name, :block, :before, :after

#name (readonly)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 12

attr_reader :name, :block, :before, :after

Instance Method Details

#belongs_to?(group) ⇒ Boolean

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 19

def belongs_to?(group)
  @group == group || @group == :all
end

#bind(context)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 27

def bind(context)
  return self if @context
  Initializer.new(@name, context, before:, after:, group: @group, &block)
end

#context_class

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 32

def context_class
  @context.class
end

#run(*args)

[ GitHub ]

  
# File 'railties/lib/rails/initializable.rb', line 23

def run(*args)
  @context.instance_exec(*args, &block)
end