module Metaractor

Special thanks to the `hashie` and `active_attr` gems for code and inspiration.

Constants

VERSION

Public Class Methods

clear_types!() click to toggle source
# File lib/metaractor.rb, line 89
def self.clear_types!
  @types = {}
end
configure() { |self| ... } click to toggle source
# File lib/metaractor.rb, line 31
def self.configure
  yield self
end
default_hash_formatter() click to toggle source
# File lib/metaractor.rb, line 69
def self.default_hash_formatter
  ->(hash){ hash.inspect }
end
default_modules() click to toggle source
# File lib/metaractor.rb, line 43
def self.default_modules
  [
    { module: Metaractor::HandleErrors, method: :include },
    { module: Metaractor::Parameters, method: :include },
    { module: Metaractor::RunWithContext, method: :include },
    { module: Metaractor::ChainFailures, method: :include },
    { module: Metaractor::Namespace, method: :include }
  ]
end
format_hash(hash) click to toggle source
# File lib/metaractor.rb, line 61
def self.format_hash(hash)
  if @hash_formatter.nil?
    @hash_formatter = default_hash_formatter
  end

  @hash_formatter.call(hash)
end
hash_formatter() click to toggle source
# File lib/metaractor.rb, line 73
def self.hash_formatter
  @hash_formatter
end
hash_formatter=(callable) click to toggle source
# File lib/metaractor.rb, line 77
def self.hash_formatter=(callable)
  @hash_formatter = callable
end
include_module(mod) click to toggle source
# File lib/metaractor.rb, line 53
def self.include_module(mod)
  modules << { module: mod, method: :include }
end
included(base) click to toggle source
# File lib/metaractor.rb, line 17
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
modules() click to toggle source
# File lib/metaractor.rb, line 35
def self.modules
  @modules ||= default_modules
end
modules=(mods) click to toggle source
# File lib/metaractor.rb, line 39
def self.modules=(mods)
  @modules = mods
end
prepend_module(mod) click to toggle source
# File lib/metaractor.rb, line 57
def self.prepend_module(mod)
  modules << { module: mod, method: :prepend }
end
register_type(type, callable) click to toggle source
# File lib/metaractor.rb, line 85
def self.register_type(type, callable)
  types[type] = callable
end
types() click to toggle source
# File lib/metaractor.rb, line 81
def self.types
  @types ||= {}
end