Sha256: fb57cb1b042bff5af246547ac0526513aefe9959e252a5d1e40d732a4eea52dc

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

module PgHero
  class Database
    attr_reader :id, :config, :connection_model

    def initialize(id, config)
      @id = id
      @config = config
    end

    def connection_model
      @connection_model ||= begin
        url = config["url"]
        Class.new(PgHero::Connection) do
          def self.name
            "PgHero::Connection::#{object_id}"
          end
          establish_connection(url) if url
        end
      end
    end

    def db_instance_identifier
      @db_instance_identifier ||= @config["db_instance_identifier"]
    end

    def name
      @name ||= @config["name"] || id.titleize
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pghero-1.2.3 lib/pghero/database.rb