Sha256: 5fcf1e148efa5f0a3f999d2bf0a54c4f8c83ff3398ed919282d65af8920eeab2
Contents?: true
Size: 752 Bytes
Versions: 2
Compression:
Stored size: 752 Bytes
Contents
module Makers class Definitions def initialize reset end def reset @makers = {} end def maker(name, options={}, &block) maker = Maker.new(name, options, &block) iterate_names name, options do |name| @makers[name] = maker end end def find(name) @makers[name].tap do |definition| raise "Definition #{name} not found" unless definition end end protected def iterate_names(name, options) names = [name] if aliases = options[:aliases] case aliases when Array names |= aliases else names << aliases end end names.each do |name| yield name end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
makers-0.1.3 | lib/makers/definitions.rb |
makers-0.1.2 | lib/makers/definitions.rb |