Class: Trowel::Sow

Inherits:
Object
  • Object
show all
Defined in:
lib/trowel/sow.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Sow

Returns a new instance of Sow.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/trowel/sow.rb', line 3

def initialize(path, options = {})
  @path, @options = path, options
  $stdout << "[Trowel::Sow] Seeding #{klass} from #{path}\n" if options[:verbose]
  YAML::load_file(path).each do |attributes|
    object = klass.new
    attributes.each { |k,v| object.send("#{k}=", v) }
    process_callback(:before_save, object)
    process_callback(:after_save, object)
    object.save!
  end
end