Class: Popper::Action::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/popper/action/base.rb

Direct Known Subclasses

ExecCmd, Git, Slack, Webhook

Class Method Summary collapse

Class Method Details

.action_nameObject



32
33
34
# File 'lib/popper/action/base.rb', line 32

def self.action_name
  self.name.split('::').last.downcase.to_sym
end

.check_paramsObject



38
# File 'lib/popper/action/base.rb', line 38

def self.check_params; end

.do_action?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/popper/action/base.rb', line 28

def self.do_action?
  @action_config && check_params
end

.next_action(action = nil) ⇒ Object



19
20
21
22
# File 'lib/popper/action/base.rb', line 19

def self.next_action(action=nil)
  @next_action = action if action
  @next_action
end

.next_run(config, mail, params = {}) ⇒ Object



24
25
26
# File 'lib/popper/action/base.rb', line 24

def self.next_run(config, mail, params={})
  @next_action.run(config, mail, params) if @next_action
end

.run(config, mail, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/popper/action/base.rb', line 6

def self.run(config, mail, params={})
  @action_config = config.send(action_name) if config.respond_to?(action_name)
  begin
    Popper.log.info "run action #{action_name}"
    params = task(mail, params)
    Popper.log.info "exit action #{action_name}"
  rescue => e
    Popper.log.warn e
    Popper.log.warn e.backtrace
  end if do_action?
  next_run(config, mail, params)
end