Class: Adhearsion::Plugin::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/plugin/initializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, context, options, &block) ⇒ Initializer

Returns a new instance of Initializer.



8
9
10
11
# File 'lib/adhearsion/plugin/initializer.rb', line 8

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/adhearsion/plugin/initializer.rb', line 6

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/adhearsion/plugin/initializer.rb', line 6

def name
  @name
end

Instance Method Details

#afterObject



17
18
19
# File 'lib/adhearsion/plugin/initializer.rb', line 17

def after
  @options[:after]
end

#beforeObject



13
14
15
# File 'lib/adhearsion/plugin/initializer.rb', line 13

def before
  @options[:before]
end

#belongs_to?(group) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/adhearsion/plugin/initializer.rb', line 21

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

#bind(context) ⇒ Object



29
30
31
32
# File 'lib/adhearsion/plugin/initializer.rb', line 29

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

#run(*args) ⇒ Object



25
26
27
# File 'lib/adhearsion/plugin/initializer.rb', line 25

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

#to_sObject



34
35
36
# File 'lib/adhearsion/plugin/initializer.rb', line 34

def to_s
  "#{self.name}: #{@options}"
end