Sha256: 1d4eb58e6a40660767bfe8570dfc8e7d0de0163cf82d0873fe85c7078c6a823d

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module ThirdBase
  class Railtie < Rails::Railtie

    config.third_base = ActiveSupport::OrderedOptions.new
    config.third_base.path = 'db/thirdbase'
    config.third_base.config_key = 'thirdbase'
    config.third_base.run_with_db_tasks = true

    config.after_initialize do |app|
      thirdbase_dir = app.root.join(config.third_base.path)
      FileUtils.mkdir(thirdbase_dir) unless File.directory?(thirdbase_dir)
    end

    rake_tasks do
      load 'third_base/databases.rake'
      
      if Rails.version.to_i == 4
        load 'third_base/databases_rails_four.rake'
      else
        load 'third_base/databases_rails_five.rake'
      end

    end

    generators do
      require 'rails/third_base/generators/migration_generator'
    end

    initializer 'third_base.add_watchable_files' do |app|
      thirdbase_dir = app.root.join(config.third_base.path)
      config.watchable_files.concat ["#{thirdbase_dir}/schema.rb", "#{thirdbase_dir}/structure.sql"]
    end

    def config_path
      config.third_base.path
    end

    def config_key
      config.third_base.config_key
    end

    def run_with_db_tasks?
      config.third_base.run_with_db_tasks
    end

    def fullpath(extra=nil)
      path = Rails.root.join(config.third_base.path)
      (extra ? path.join(path, extra) : path).to_s
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thirdbase-2.1.2 lib/third_base/railtie.rb
thirdbase-2.1.1 lib/third_base/railtie.rb