Sha256: 8d4eaf44970c766d06ab6d630da8e00056cf29ecd41d53f5017d9dedc3502be2

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 Bytes

Contents

module CassandraObject
  class Railtie < Rails::Railtie
    rake_tasks do
      load 'cassandra_object/tasks/ks.rake'
    end

    initializer "cassandra_object.log_runtime" do |app|
      ActiveSupport.on_load :cassandra_object do
        pathname = Rails.root.join('config', 'cassandra.yml')
        if pathname.exist?
          config = YAML.load(pathname.read)

          if config = config[Rails.env]
            self.config = {
              keyspace: config['keyspace'],
              servers: config['servers'],
              thrift: config['thrift']
            }
          else
            raise "Missing environment #{Rails.env} in cassandra.yml"
          end
        end
      end
    end

    # Expose database runtime to controller for logging.
    initializer "cassandra_object.log_runtime" do |app|
      require "cassandra_object/railties/controller_runtime"
      ActiveSupport.on_load(:action_controller) do
        include CassandraObject::Railties::ControllerRuntime
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 lib/cassandra_object/railtie.rb
gotime-cassandra_object-4.12.1 lib/cassandra_object/railtie.rb
gotime-cassandra_object-4.12.0 lib/cassandra_object/railtie.rb