Sha256: 1837630b0b76d933ce18efb149af2afed9c14abebc26a191f9bfb15b33851042

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

module RakeTaskHelpers  
  def seeds
    @seeds ||= get_seeds
  end
  
  def get_seeds
    Dir[File.join(Rails.root, 'db','seeds', '*')].reduce({}) do |seeds, seed|
      load(seed)
        
      seed_klass = seed_klass_from_path(seed)
      seeds[seed_klass.seed_name] = seed_klass
      seeds
    end
  end
  
  def verify_seed(seed)
    abort "Unknown seed #{seed}" unless seeds[seed]
  end
  
  def seed_klass_from_path(path)
    puts path
    (path.split("/").last.gsub(/\.rb/,'') + 'Seed').classify.constantize    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ambitious_seeder-0.1.0 lib/tasks/support/rake_task_helpers.rb