Sha256: 125998010e08d4a7b3c058e6b10651ecf21f85263b7908573a4e5f64481c8f4f

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'metaractor/version'
require 'interactor'
require 'metaractor/errors'
require 'metaractor/parameters'
require 'metaractor/run_with_context'
require 'metaractor/context_validity'

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::Errors, method: :include },
      { module: Metaractor::Parameters, method: :include },
      { module: Metaractor::RunWithContext, 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

1 entries across 1 versions & 1 rubygems

Version Path
metaractor-0.5.0 lib/metaractor.rb