class Lita::PluginBuilder
Constructs a Lita plugin from a block. @since 4.0.0 @api private
Public Class Methods
new(namespace, &block)
click to toggle source
@param namespace [String, Symbol] The Redis namespace to use for the plugin. @yield The class body of the plugin.
# File lib/lita/plugin_builder.rb, line 8 def initialize(namespace, &block) @namespace = namespace.to_s @block = block end
Public Instance Methods
build_adapter()
click to toggle source
Constructs an {Lita::Adapter} from the provided block. @return [Lita::Adapter]
# File lib/lita/plugin_builder.rb, line 15 def build_adapter adapter = create_plugin(Adapter) adapter.class_exec(&@block) adapter end
build_handler()
click to toggle source
Constructs a {Lita::Handler} from the provided block. @return [Lita::Handler]
# File lib/lita/plugin_builder.rb, line 23 def build_handler handler = create_plugin(Handler) handler.class_exec(&@block) handler end
Private Instance Methods
create_plugin(plugin_type)
click to toggle source
Creates a class of the relevant plugin type and sets its namespace.
# File lib/lita/plugin_builder.rb, line 32 def create_plugin(plugin_type) plugin = Class.new(plugin_type) plugin.namespace(@namespace) plugin end