Sha256: 7b13fdf6b84f0f10dcfe63e32fb37b004272bfbe97b07773a254eb1e2e0d66e2
Contents?: true
Size: 521 Bytes
Versions: 5
Compression:
Stored size: 521 Bytes
Contents
require "adt/version" require "adt/constructor" module ADT end def ADT(&block) Class.new.tap do |klass| o = Object.new o.define_singleton_method(:method_missing) do |m, *args, &block| ADT::Constructor.new(klass, m, args.first || {}, &block) end first = o.instance_eval(&block) [first, *first.others].each do |tc| klass.const_set(tc.name, tc.klass) klass.singleton_class.send(:define_method, tc.name) do |*args| const_get(tc.name).new(*args) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
adts-0.1.2 | lib/adt.rb |
adts-0.1.1 | lib/adt.rb |
adts-0.1.0 | lib/adt.rb |
adts-0.0.2 | lib/adt.rb |
adts-0.0.1 | lib/adt.rb |