class Seahorse::Client::Plugin
Public Class Methods
after_initialize(&block)
click to toggle source
# File lib/seahorse/client/plugin.rb, line 71 def after_initialize(&block) after_initialize_hooks << block end
after_initialize_hooks()
click to toggle source
@api private
# File lib/seahorse/client/plugin.rb, line 91 def after_initialize_hooks @after_initialize_hooks ||= [] end
before_initialize(&block)
click to toggle source
# File lib/seahorse/client/plugin.rb, line 67 def before_initialize(&block) before_initialize_hooks << block end
before_initialize_hooks()
click to toggle source
@api private
# File lib/seahorse/client/plugin.rb, line 86 def before_initialize_hooks @before_initialize_hooks ||= [] end
handlers()
click to toggle source
@api private
# File lib/seahorse/client/plugin.rb, line 81 def handlers @handlers ||= HandlerList.new end
literal(string)
click to toggle source
@api private
# File lib/seahorse/client/plugin.rb, line 96 def literal(string) CodeLiteral.new(string) end
option(name, default = nil, options = {}, &block)
click to toggle source
@overload option(name, options = {}, &block) @option options [Object] :default Can also be set by passing a block. @option options [String] :doc_default @option options [Boolean] :required @option options [String] :doc_type @option options [String] :docs @return [void]
# File lib/seahorse/client/plugin.rb, line 54 def option(name, default = nil, options = {}, &block) # For backwards-compat reasons, the default value can be passed as 2nd # positional argument (before the options hash) or as the `:default` option # in the options hash. if default.is_a? Hash options = default else options[:default] = default end options[:default_block] = block if block_given? self.options << PluginOption.new(name, options) end
options()
click to toggle source
@api private
# File lib/seahorse/client/plugin.rb, line 76 def options @options ||= [] end
Public Instance Methods
add_handlers(handlers, config)
click to toggle source
@param [HandlerList] handlers @param [Configuration] config @return [void]
# File lib/seahorse/client/plugin.rb, line 24 def add_handlers(handlers, config) handlers.copy_from(self.class.handlers) end
add_options(config)
click to toggle source
@param [Configuration] config @return [void]
# File lib/seahorse/client/plugin.rb, line 11 def add_options(config) self.class.options.each do |option| if option.default_block config.add_option(option.name, &option.default_block) else config.add_option(option.name, option.default) end end end
after_initialize(client)
click to toggle source
@param [Client::Base] client @return [void]
# File lib/seahorse/client/plugin.rb, line 39 def after_initialize(client) self.class.after_initialize_hooks.each do |block| block.call(client) end end
before_initialize(client_class, options)
click to toggle source
@param [Class<Client::Base>] client_class @param [Hash] options @return [void]
# File lib/seahorse/client/plugin.rb, line 31 def before_initialize(client_class, options) self.class.before_initialize_hooks.each do |block| block.call(client_class, options) end end