class KafoWizards::Factory

Public Class Methods

new(wizard=nil) click to toggle source
# File lib/kafo_wizards/factory.rb, line 9
def initialize(wizard=nil)
  @wizard = wizard
end

Public Instance Methods

method_missing(meth, *args, &block) click to toggle source
# File lib/kafo_wizards/factory.rb, line 13
def method_missing(meth, *args, &block)
  if @wizard
    args << {} unless args.last.class <= Hash
    args[-1][:parent] = @wizard unless args[-1].has_key?(:parent)
  end

  entry_cls = KafoWizards::Entries::AbstractEntry.descendants.find { |ec| ec.entry_type == meth }
  raise NameError.new "Unknown type of entry (#{meth.to_s})" unless entry_cls
  entry_cls.new(*args)
end