Sha256: c342ea631a205db8edc9033d20ab4b7f0df0618bc763e493285481a8da9d1ff9
Contents?: true
Size: 705 Bytes
Versions: 14
Compression:
Stored size: 705 Bytes
Contents
module With module Sharing def share(group, name = nil, &block) context = Context.new(name || group, &block) context.instance_eval &block if block self.shared[group] ||= [] self.shared[group] << context end def shared(name = nil) @@shared ||= {} name.nil? ? @@shared : begin raise "could not find shared context #{name.inspect}" unless @@shared.has_key?(name) @@shared[name].map {|context| context.clone } end end def share_condition(name, &block) @@conditions ||= {} @@conditions[name] = block end def condition(name) @@conditions ||= {} @@conditions[name] end end end
Version data entries
14 entries across 14 versions & 1 rubygems