Sha256: 7536414077b3c9e863442bafaaa49bcc949a1430f285ecc69e3262ad3a86ecdd
Contents?: true
Size: 475 Bytes
Versions: 24
Compression:
Stored size: 475 Bytes
Contents
module Dragonfly class Register # Exceptions class NotFound < RuntimeError; end def initialize @items = {} end attr_reader :items def add(name, item=nil, &block) items[name.to_sym] = item || block || raise(ArgumentError, "you must give either an argument or a block") end def get(name) items[name.to_sym] || raise(NotFound, "#{name.inspect} not registered") end def names items.keys end end end
Version data entries
24 entries across 24 versions & 1 rubygems