Class: Popper::Action::Base
- Inherits:
-
Object
- Object
- Popper::Action::Base
- Defined in:
- lib/popper/action/base.rb
Class Method Summary collapse
- .action_name ⇒ Object
- .check_params ⇒ Object
- .do_action? ⇒ Boolean
- .next_action(action = nil) ⇒ Object
- .next_run(config, mail, params = {}) ⇒ Object
- .run(config, mail, params = {}) ⇒ Object
Class Method Details
.action_name ⇒ Object
32 33 34 |
# File 'lib/popper/action/base.rb', line 32 def self.action_name self.name.split('::').last.downcase.to_sym end |
.check_params ⇒ Object
38 |
# File 'lib/popper/action/base.rb', line 38 def self.check_params; end |
.do_action? ⇒ 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 |