Class: SeedFu::Writer::Seed

Inherits:
Abstract show all
Defined in:
lib/seed-fu/writer/seed.rb

Instance Attribute Summary

Attributes inherited from Abstract

#config, #number_of_seeds, #seed_handle

Instance Method Summary collapse

Methods inherited from Abstract

#finish, #footer, #header, #initialize, #write_footer, #write_header

Constructor Details

This class inherits a constructor from SeedFu::Writer::Abstract

Instance Method Details

#add_seed(hash, seed_by = nil) ⇒ Object

This method uses the :seed_by set earlier.


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/seed-fu/writer/seed.rb', line 9

def add_seed(hash, seed_by=nil)
  seed_by ||= config[:seed_by]
  seed_handle.syswrite( <<-END
#{config[:seed_model]}.seed(#{seed_by.collect{|s| ":#{s}"}.join(',')}) { |s|
#{hash.collect{|k,v| "  s.#{k} = '#{v.to_s.gsub("'", "\'")}'\n"}.join}}
  END
  )
  super(hash)
  if chunk_this_seed?
    seed_handle.syswrite "# BREAK EVAL\n"
  end
end