Module: Zen::Service::Plugins::Status

Extended by:
Plugin
Defined in:
lib/zen/service/plugins/status.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Plugin

config, default_options, extended, register_as, service_extension

Class Method Details

.configure(service_class, success:, failure:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zen/service/plugins/status.rb', line 18

def self.configure(service_class, success:, failure:)
  service_class::StatusHelpers.module_eval do
    success.each do |name|
      define_method(name) do |**opts, &block|
        success(status: name, **opts, &block)
      end
    end

    failure.each do |name|
      define_method(name) do |**opts, &block|
        failure(status: name, **opts, &block)
      end
    end
  end
end

.used(service_class) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/zen/service/plugins/status.rb', line 10

def self.used(service_class, **)
  service_class.add_execution_prop(:status)

  helpers = Module.new
  service_class.const_set(:StatusHelpers, helpers)
  service_class.send(:include, helpers)
end

Instance Method Details

#statusObject



34
35
36
# File 'lib/zen/service/plugins/status.rb', line 34

def status
  state.status
end