Module: Chargify::Loops

Defined in:
lib/chargify/loops.rb,
lib/chargify/loops/version.rb

Defined Under Namespace

Classes: Engine

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.delegate_hook(event, payload) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/chargify/loops.rb', line 3

def self.delegate_hook(event, payload)
  loops[event].each do |block|
    block.call payload
  end

  loops[:all].each do |block|
    block.call event, payload
  end
end

.loop!(event, &block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/chargify/loops.rb', line 17

def self.loop!(event, &block)
  events = event.kind_of?(Array) ? event : [event]
  events.each do |event|
    loops[event] ||= []
    loops[event]  << block
  end
end

.loopsObject



13
14
15
# File 'lib/chargify/loops.rb', line 13

def self.loops
  @loops ||= Hash.new { |hash, key| hash[key] = [] }
end

.shared_keyObject



25
26
27
# File 'lib/chargify/loops.rb', line 25

def self.shared_key
  @shared_key || ''
end

.shared_key=(key) ⇒ Object



29
30
31
# File 'lib/chargify/loops.rb', line 29

def self.shared_key=(key)
  @shared_key = key
end