Class: EY::Serverside::Callbacks::Collection::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-serverside/callbacks/collection/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 14

def initialize(paths)
  @paths = paths
  load_hooks
end

Class Method Details

.load(paths) ⇒ Object



10
11
12
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 10

def self.load(paths)
  new(paths)
end

Instance Method Details

#allObject



19
20
21
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 19

def all
  hooks
end

#distribute(runner, callback) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 34

def distribute(runner, callback)
  Distributor.distribute(
    runner,
    minimize_ruby(
      matching(callback)
    )
  )
end

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 23

def empty?
  hooks.empty?
end

#execute(config, shell, callback) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 43

def execute(config, shell, callback)
  matches = matching(callback)

  if matches.empty?
    shell.info("No hooks detected for #{callback}. Skipping.")
    return
  end

  Executor.execute(config, shell, matches)
end

#matching(callback) ⇒ Object



27
28
29
30
31
32
# File 'lib/engineyard-serverside/callbacks/collection/base.rb', line 27

def matching(callback)
  favor(
    :ruby,
    all.select {|hook| hook.matches?(callback.to_sym)}
  )
end