Module: Lita::Handler::Common::ClassMethods
- Defined in:
- lib/lita/handler/common.rb
Overview
Common class-level methods for all handlers.
Instance Method Summary collapse
-
#log_error(robot, error) ⇒ Object
Logs an error raised by a plugin.
-
#template_root(path = nil) ⇒ String
Gets (and optionally sets) the directory where the handler’s templates are stored.
-
#translate(key, hash = {}) ⇒ String
(also: #t)
Returns the translation for a key, automatically namespaced to the handler.
Instance Method Details
#log_error(robot, error) ⇒ Object
Logs an error raised by a plugin.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lita/handler/common.rb', line 42 def log_error(robot, error) robot.config.robot.error_handler.call(error) Lita.logger.error I18n.t( "lita.handler.exception", handler: name, message: error., backtrace: error.backtrace.join("\n") ) raise error if Lita.test_mode? end |
#template_root(path = nil) ⇒ String
Gets (and optionally sets) the directory where the handler’s templates are stored.
20 21 22 23 24 25 26 27 28 |
# File 'lib/lita/handler/common.rb', line 20 def template_root(path = nil) @template_root = path if path if defined?(@template_root) return @template_root else raise MissingTemplateRootError end end |
#translate(key, hash = {}) ⇒ String Also known as: t
Returns the translation for a key, automatically namespaced to the handler.
35 36 37 |
# File 'lib/lita/handler/common.rb', line 35 def translate(key, hash = {}) I18n.translate("lita.handlers.#{namespace}.#{key}", **hash) end |