Sha256: 0885a387efb3e3153d0377a0f2d5cd560489ec1dc30f5bde33fb3190110145f6

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'metaractor/version'
require 'interactor'
require 'metaractor/errors'
require 'metaractor/handle_errors'
require 'metaractor/context_errors'
require 'metaractor/parameters'
require 'metaractor/run_with_context'
require 'metaractor/context_validity'
require 'metaractor/chain_failures'
require 'metaractor/fail_from_context'
require 'metaractor/context_has_key'
require 'metaractor/failure_output'

module Metaractor
  def self.included(base)
    base.class_eval do
      include Interactor
      Metaractor.modules.each do |hsh|
        case hsh[:method]
        when :include
          include hsh[:module]
        when :prepend
          prepend hsh[:module]
        end
      end
    end
  end

  def self.configure
    yield self
  end

  def self.modules
    @modules ||= default_modules
  end

  def self.modules=(mods)
    @modules = mods
  end

  def self.default_modules
    [
      { module: Metaractor::HandleErrors, method: :include },
      { module: Metaractor::Parameters, method: :include },
      { module: Metaractor::RunWithContext, method: :include },
      { module: Metaractor::ChainFailures, method: :include }
    ]
  end

  def self.include_module(mod)
    modules << { module: mod, method: :include }
  end

  def self.prepend_module(mod)
    modules << { module: mod, method: :prepend }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metaractor-2.1.1 lib/metaractor.rb
metaractor-2.1.0 lib/metaractor.rb