Class: Rails::Initializable::Initializer

Inherits:
Object
  • Object
show all
Defined in:
railties/lib/rails/initializable.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Initializer) initialize(name, context, options, &block)

Returns a new instance of Initializer



12
13
14
15
# 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

- (Object) block (readonly)

Returns the value of attribute block



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

def block
  @block
end

- (Object) name (readonly)

Returns the value of attribute name



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

def name
  @name
end

Instance Method Details

- (Object) after



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

def after
  @options[:after]
end

- (Object) before



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

def before
  @options[:before]
end

- (Boolean) belongs_to?(group)

Returns:

  • (Boolean)


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

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

- (Object) bind(context)



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

- (Object) run(*args)



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

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