Sha256: 5e989a5a67d36f92c95b3a559b8e57568be8e4093bf46d568a79ad667e97c967
Contents?: true
Size: 795 Bytes
Versions: 1
Compression:
Stored size: 795 Bytes
Contents
require "separatum/version" Dir[File.expand_path(File.join(__FILE__, %w(.. ** *.rb)))].each(&method(:require)) module Separatum def self.build(&block) instance = Class.new.include(StackMethods).new stack = instance.instance_eval(&block) Stack.new(stack: stack) end module StackMethods def use(klass, *params) fail unless klass.is_a?(Class) (@stack ||= []) << [klass, *params] end end class Stack def initialize(stack:) @stack = stack end def call(*options) current_options = options current_result = nil @stack.each do |el| klass, *params = el instance = klass.new(*params) current_result = instance.(*(current_result || current_options)) end current_result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
separatum-0.1.0 | lib/separatum.rb |