Sha256: 410243d605535413cd47f804a3f608e663a3339cf4f66639fddc08f51568fa7b
Contents?: true
Size: 699 Bytes
Versions: 1
Compression:
Stored size: 699 Bytes
Contents
module Yaks module Configurable def config_method(name, options) define_method name do |*args, &block| defaults = options.fetch(:defaults, {}) klass = options.fetch(:create) instance = if args.length.equal?(1) && args.first.instance_of?(klass) args.first else if args.last.instance_of?(Hash) args[-1] = defaults.merge(args[-1]) else args << defaults end klass.create(*args, &block) end append_to(options.fetch(:append_to), instance) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.7.7 | lib/yaks/configurable.rb |