lib/checkpoint/railtie.rb in checkpoint-1.0.0 vs lib/checkpoint/railtie.rb in checkpoint-1.0.1

- old
+ new

@@ -40,27 +40,27 @@ def when_checkpoint_is_ready(&block) ready_blocks << block end def before_blocks - @before ||= [] + @before_blocks ||= [] end def after_blocks - @after ||= [] + @after_blocks ||= [] end def ready_blocks - @ready ||= [] + @ready_blocks ||= [] end def under_rake! - @rake = true + @under_rake = true end def under_rake? - @rake ||= false + @under_rake ||= false end end # This runs before anything in 'config/initializers' runs. initializer "checkpoint.before_initializers", before: :load_config_initializers do @@ -80,26 +80,24 @@ initializer "checkpoint.after_initializers", after: :load_config_initializers do config = Checkpoint::DB.config Railtie.after_blocks.each do |block| block.call(config.to_h) end - end - # This runs before any block registered under a `config.to_prepare`, which - # could be in plugins or initializers that want to use a fully configured - # Checkpoint instance. The `to_prepare` hook is run once at the start of a - # production instance and for every request in development (unless caching - # is turned on so there is no reloading). - initializer "checkpoint.ready", after: :finisher_hook do Checkpoint::DB.initialize! unless Railtie.under_rake? Railtie.ready_blocks.each do |block| block.call(Checkpoint::DB.db) end end + def rake_files + base = Pathname(__dir__) + '../tasks/' + [base + 'migrate.rake'] + end + rake_tasks do Railtie.under_rake! - load "tasks/migrate.rake" + rake_files.each { |file| load file } end end end