Module: Summoner::ClassMethods

Defined in:
lib/summoner.rb

Instance Method Summary collapse

Instance Method Details

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



48
49
50
51
52
53
54
55
56
57
# File 'lib/summoner.rb', line 48

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