Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Lotus::Model::Adapter with Lotus::Model::Config::Adapter
- Loading branch information
Trung Lê
committed
Jul 14, 2014
1 parent
85a0b6f
commit fb3cfe8
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module Lotus | ||
module Model | ||
module Config | ||
# Configuration for the adapter | ||
# | ||
# Lotus::Model has its own global configuration that can be manipulated | ||
# via `Lotus::Model.configure`. | ||
# | ||
# New adapter configuration can be registered via `Lotus::Model.adapter`. | ||
# | ||
# @see Lotus::Model.adapter | ||
# | ||
# @example | ||
# require 'lotus/model' | ||
# | ||
# Lotus::Model.configure do | ||
# adapter :sql, 'postgres://localhost/database' | ||
# end | ||
# | ||
# Registered adapters can be retrieved via `Lotus::Model.adapters` | ||
# | ||
# @see Lotus::Model.adapters | ||
# | ||
# @example | ||
# Lotus::Model.adapter[:sql] | ||
# # => Lotus::Model::Config::Adapter(name: :sql, uri: 'postgres://localhost/database') | ||
# | ||
# @since 0.2.0 | ||
class Adapter | ||
# @return name [Symbol] the unique adapter name | ||
# | ||
# @since 0.2.0 | ||
# | ||
# @see Lotus::Config::Adapter#name | ||
attr_reader :name | ||
|
||
# @return uri [String] the adapter URI | ||
# | ||
# @since 0.2.0 | ||
# | ||
# @see Lotus::Config::Adapter#uri | ||
attr_reader :uri | ||
|
||
# @return default [TrueClass, FalseClass] Decide if the adapter | ||
# is used by default | ||
# | ||
# @since 0.2.0 | ||
# | ||
# @see Lotus::Config::Adapter#default | ||
attr_reader :default | ||
|
||
# Initialize an adapter configuration instance | ||
# | ||
# @return [Lotus::Model::Config::Adapter] a new apdapter configuration's | ||
# instance | ||
# | ||
# @since 0.2.0 | ||
def initialize(name, uri, default = false) | ||
@name, @uri, @default = name, uri, default | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters