Class: PINS::Handler
- Inherits:
-
Object
- Object
- PINS::Handler
- Defined in:
- lib/postmark-inbound/handler.rb
Class Method Summary collapse
-
.add(&block) ⇒ Object
Call as often as necessary to add handlers; each call creates a PINS::Handler object.
-
.autoload ⇒ Object
Load handlers from directories designated in config.
-
.handlers ⇒ Array
Containing all the handlers.
-
.load_from_path(path) ⇒ Object
Load handlers from a directory.
-
.run_handlers(pin) ⇒ Object
Run the handlers, typically called by the server.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Handler
constructor
A new instance of Handler.
- #run(obj) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Handler
Returns a new instance of Handler.
44 45 46 |
# File 'lib/postmark-inbound/handler.rb', line 44 def initialize(&block) @block = block end |
Class Method Details
.add(&block) ⇒ Object
Call as often as necessary to add handlers; each call creates a PINS::Handler object
25 26 27 28 29 |
# File 'lib/postmark-inbound/handler.rb', line 25 def self.add(&block) @handlers ||= [] @handlers << Handler.new(&block) PINS.logger.debug("Added handler: #{@handlers.last}") end |
.autoload ⇒ Object
Load handlers from directories designated in config
10 11 12 13 14 |
# File 'lib/postmark-inbound/handler.rb', line 10 def self.autoload PINS.config.handler_paths.each { |path| load_from_path(path) } end |
.handlers ⇒ Array
Returns containing all the handlers.
32 33 34 |
# File 'lib/postmark-inbound/handler.rb', line 32 def self.handlers @handlers end |
.load_from_path(path) ⇒ Object
Load handlers from a directory
18 19 20 21 22 |
# File 'lib/postmark-inbound/handler.rb', line 18 def self.load_from_path(path) Dir.chdir(path) { Dir.foreach('.') { |f| load f unless File.directory?(f) } } end |