class Doem::Registry

common registry

Public Class Methods

new() click to toggle source
# File lib/doem/registry.rb, line 11
def initialize
  @items = []
end

Public Instance Methods

<<(val) click to toggle source
# File lib/doem/registry.rb, line 19
def <<(val)
  klass = val[:klass]
  block = val[:block]
  if klass
    fail "#{klass.name} needs to implement methods: "\
      "#{mandatory_methods}" unless valid? klass
    @items << val[:klass].new(*val[:args])
  elsif block
    @items << CompatiableProc.new(&block)
  else
    fail 'registry error'
  end
end
each() { |item| ... } click to toggle source
# File lib/doem/registry.rb, line 39
def each
  @items.each do |item|
    yield item
  end
end
mandatory_methods() click to toggle source
# File lib/doem/registry.rb, line 15
def mandatory_methods
  []
end
valid?(klass) click to toggle source
# File lib/doem/registry.rb, line 33
def valid?(klass)
  mandatory_methods.all? do |m|
    klass.method_defined? m
  end
end