Sha256: 969b19abc53e580b968d7c56f148f0489d979cd4cdcf548b2e4a7bb20f994ecd
Contents?: true
Size: 1.02 KB
Versions: 5
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Light module Services class Base # Includes include Light::Services::Parameters include Light::Services::Outputs include Light::Services::Callbacks # Getters attr_reader :errors, :warnings def initialize(args = {}) @args = args initialize_params initialize_outputs @errors = Light::Services::Messages.new @warnings = Light::Services::Messages.new end def call run_service end def success? errors.blank? end def any_warnings? warnings.any? end class << self def call(args = {}) new(args).tap(&:call) end alias run call end private # Getters attr_reader :args def run_service run_callbacks(:before) run if success? run_callbacks(:after) if success? run_callbacks(:finally, force_run: true) success? end end end end
Version data entries
5 entries across 5 versions & 1 rubygems