Sha256: 9ecfac8452e8629e456b6ab6c180890218c9f24c1eeadedc55aee058ba939206
Contents?: true
Size: 899 Bytes
Versions: 22
Compression:
Stored size: 899 Bytes
Contents
require 'xommelier' module Xommelier class Collection < Hash def initialize(klass) @klass = klass end def respond_to?(name) key?(name) || super(name) end def find_and_append(name, options = {}, &block) item = self[name] item.options = options if block_given? item.scoped(&block) end item end def method_missing(name, options = {}, &block) if key?(name) find_and_append(name, options, &block) else super end end def find_or_create(name, options = {}, &block) if key?(name) find_and_append(name, options, &block) else @klass.new(name, options, &block) end end def inspect values.map { |value| value.inspect }.inspect end def pretty_inspect values.map { |value| value.inspect }.pretty_inspect end end end
Version data entries
22 entries across 22 versions & 1 rubygems