Module: RailsSeeder

Defined in:
lib/rails_seeder.rb

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rails_seeder.rb', line 64

def self.new(*args, &block)
  name, arg_names, deps = Rake.application.resolve_args(args, &block)

  unless defined? @@regenerate_defined
    desc "run all generate tasks"
    task :generate

    namespace :assets do
      task :delete
    end

    desc "reset db, delete assets and run all generate tasks"
    task :regenerate => 'db:migrate:reset'
    task :regenerate => 'assets:delete'
    task :regenerate => :generate

    @@regenerate_defined = true
  end

  task :generate => "generate:#{name}"

  namespace :generate do
    desc "generate #{name}"
    task name => [:environment, deps].flatten.compact do
      block.binding.eval("include #{self.name}::Helpers", __FILE__, __LINE__)
      block.call
    end
  end
end