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, options, &block) ⇒ Initializer

[ GitHub ]

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

def initialize(name, context, options, &block)
  options[:group] ||= :default
  @name, @context, @options, @block = name, context, options, block
end

Instance Attribute Details

#block (readonly)

[ GitHub ]

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

attr_reader :name, :block

#name (readonly)

[ GitHub ]

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

attr_reader :name, :block

Instance Method Details

#after

[ GitHub ]

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

def after
  @options[:after]
end

#before

[ GitHub ]

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

def before
  @options[:before]
end

#belongs_to?(group) ⇒ Boolean

[ GitHub ]

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

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

#bind(context)

[ GitHub ]

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

def bind(context)
  return self if @context
  Initializer.new(@name, context, @options, &block)
end

#run(*args)

[ GitHub ]

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

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