Class: Rails::Initializable::Initializer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options, &block)
  @name, @context, @options, @block = name, context, options, block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#afterObject



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

def after
  @options[:after]
end

#beforeObject



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