Module: Summoner::ClassMethods

Defined in:
lib/summoner.rb

Instance Method Summary collapse

Instance Method Details

#summon(options = {}, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/summoner.rb', line 40

def summon(options = {}, &block)
  begin
    object = self.create(options)
    yield object if block_given?
    object.save(false)
    object
  rescue ArgumentError
    puts "You're probably summoning something by itself. Try defining attributes as attr = value"
  end
end