Module: Setsuzoku::Pluggable::ClassMethods

Extended by:
T::Sig
Defined in:
lib/setsuzoku/pluggable.rb

Instance Method Summary collapse

Instance Method Details

#default_optionsObject



52
53
54
55
56
# File 'lib/setsuzoku/pluggable.rb', line 52

def default_options
  {
      plugin_class: self
  }
end

#finalVoid

Upon class load (or whenever you call this) register the core configuration for the pluggable class.

param options [Any] a list of keyword options to be passed in to customize registration.

Returns:

  • (Void)


64
# File 'lib/setsuzoku/pluggable.rb', line 64

sig(:final) { params(options: T.untyped).void }

#plugin_classObject



45
46
47
# File 'lib/setsuzoku/pluggable.rb', line 45

def plugin_class
  @plugin_class
end

#plugin_class=(val) ⇒ Object



48
49
50
# File 'lib/setsuzoku/pluggable.rb', line 48

def plugin_class=(val)
  @plugin_class = val
end

#plugin_contextObject



39
40
41
# File 'lib/setsuzoku/pluggable.rb', line 39

def plugin_context
  @plugin_context
end

#plugin_context=(val) ⇒ Object



42
43
44
# File 'lib/setsuzoku/pluggable.rb', line 42

def plugin_context=(val)
  @plugin_context = val
end

#register_plugin(**options) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/setsuzoku/pluggable.rb', line 65

def register_plugin(**options)
  options[:plugin_class].config_context[:required_instance_methods].each do |req_method|
    next if options[:required_instance_methods].key?(req_method)
    raise Setsuzoku::Exception::UndefinedRequiredMethod.new(
        registering_instance: self,
        plugin_class: options[:plugin_class],
        method_name: req_method
    )
  end

  self.plugin_context = self.default_options.merge(options)
end