Class: DataMapper::Spec::Adapters::Adapter

### Home Classes Methods

### In Files

- lib/dm-core/spec/setup.rb

### Parent

Object

### Methods

- ::new
- #adapter
- #adapter_name
- #alternate_storage_name
- #connection_uri
- #default_storage_name
- #host
- #password
- #setup
- #setup!
- #storage_name
- #test_connection
- #username

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Adapters
- DataMapper::Adapters::AbstractAdapter
- DataMapper::Adapters::InMemoryAdapter
- DataMapper::Assertions
- DataMapper::Associations
- DataMapper::Associations::ManyToMany
- DataMapper::Associations::ManyToMany::Collection
- DataMapper::Associations::ManyToMany::Relationship
- DataMapper::Associations::ManyToOne
- DataMapper::Associations::ManyToOne::Relationship
- DataMapper::Associations::OneToMany
- DataMapper::Associations::OneToMany::Collection
- DataMapper::Associations::OneToMany::Relationship
- DataMapper::Associations::OneToOne
- DataMapper::Associations::OneToOne::Relationship
- DataMapper::Associations::Relationship
- DataMapper::Chainable
- DataMapper::Collection
- DataMapper::Deprecate
- DataMapper::DescendantSet
- DataMapper::Equalizer
- DataMapper::Ext
- DataMapper::Ext::Array
- DataMapper::Ext::Hash
- DataMapper::Ext::Module
- DataMapper::Ext::Object
- DataMapper::Ext::String
- DataMapper::Hook
- DataMapper::Hook::ClassMethods
- DataMapper::IdentityMap
- DataMapper::ImmutableDeletedError
- DataMapper::ImmutableError
- DataMapper::IncompleteModelError
- DataMapper::Inflector
- DataMapper::Inflector::Inflections
- DataMapper::LocalObjectSpace
- DataMapper::Logger
- DataMapper::Mash
- DataMapper::Model
- DataMapper::Model::Hook
- DataMapper::Model::Hook::MethodCommand
- DataMapper::Model::Hook::Methods
- DataMapper::Model::Hook::ProcCommand
- DataMapper::Model::Is
- DataMapper::Model::Property
- DataMapper::Model::Relationship
- DataMapper::Model::Scope
- DataMapper::NamingConventions
- DataMapper::NamingConventions::Field
- DataMapper::NamingConventions::Field::Underscored
- DataMapper::NamingConventions::Field::UnderscoredAndPluralized
- DataMapper::NamingConventions::Field::UnderscoredAndPluralizedWithoutModule
- DataMapper::NamingConventions::Field::Yaml
- DataMapper::NamingConventions::Resource
- DataMapper::NamingConventions::Resource::Underscored
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralized
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutLeadingModule
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutModule
- DataMapper::NamingConventions::Resource::Yaml
- DataMapper::ObjectNotFoundError
- DataMapper::OrderedSet
- DataMapper::OrderedSet::Cache
- DataMapper::OrderedSet::Cache::API
- DataMapper::PersistenceError
- DataMapper::PluginNotFoundError
- DataMapper::Property
- DataMapper::Property::Binary
- DataMapper::Property::Boolean
- DataMapper::Property::Class
- DataMapper::Property::Date
- DataMapper::Property::DateTime
- DataMapper::Property::Decimal
- DataMapper::Property::Discriminator
- DataMapper::Property::Discriminator::Model
- DataMapper::Property::Float
- DataMapper::Property::Integer
- DataMapper::Property::Lookup
- DataMapper::Property::Numeric
- DataMapper::Property::Object
- DataMapper::Property::PassThroughLoadDump
- DataMapper::Property::Serial
- DataMapper::Property::String
- DataMapper::Property::Text
- DataMapper::Property::Time
- DataMapper::Property::Typecast
- DataMapper::Property::Typecast::Numeric
- DataMapper::Property::Typecast::Time
- DataMapper::PropertySet
- DataMapper::Query
- DataMapper::Query::Conditions
- DataMapper::Query::Conditions::AbstractComparison
- DataMapper::Query::Conditions::AbstractOperation
- DataMapper::Query::Conditions::AndOperation
- DataMapper::Query::Conditions::Comparison
- DataMapper::Query::Conditions::EqualToComparison
- DataMapper::Query::Conditions::FlattenOperation
- DataMapper::Query::Conditions::GreaterThanComparison
- DataMapper::Query::Conditions::GreaterThanOrEqualToComparison
- DataMapper::Query::Conditions::InclusionComparison
- DataMapper::Query::Conditions::LessThanComparison
- DataMapper::Query::Conditions::LessThanOrEqualToComparison
- DataMapper::Query::Conditions::LikeComparison
- DataMapper::Query::Conditions::NotOperation
- DataMapper::Query::Conditions::NullOperation
- DataMapper::Query::Conditions::Operation
- DataMapper::Query::Conditions::OrOperation
- DataMapper::Query::Conditions::RegexpComparison
- DataMapper::Query::Conditions::RelationshipHandler
- DataMapper::Query::Direction
- DataMapper::Query::Operator
- DataMapper::Query::Path
- DataMapper::Query::Sort
- DataMapper::RelationshipSet
- DataMapper::Repository
- DataMapper::RepositoryNotSetupError
- DataMapper::Resource
- DataMapper::Resource::PersistenceState
- DataMapper::Resource::PersistenceState::Clean
- DataMapper::Resource::PersistenceState::Deleted
- DataMapper::Resource::PersistenceState::Dirty
- DataMapper::Resource::PersistenceState::Immutable
- DataMapper::Resource::PersistenceState::Persisted
- DataMapper::Resource::PersistenceState::Transient
- DataMapper::SaveFailureError
- DataMapper::Spec
- DataMapper::Spec::Adapters
- DataMapper::Spec::Adapters::Adapter
- DataMapper::Spec::Adapters::Helpers
- DataMapper::Spec::Adapters::InMemoryAdapter
- DataMapper::Spec::CollectionHelpers
- DataMapper::Spec::CollectionHelpers::GroupMethods
- DataMapper::Spec::Helpers
- DataMapper::Spec::PendingHelpers
- DataMapper::Subject
- DataMapper::SubjectSet
- DataMapper::SubjectSet::NameCache
- DataMapper::Undefined
- DataMapper::UnknownRelationshipError
- DataMapper::UnsavedParentError
- DataMapper::UpdateConflictError
- Blog
- Blog::Article
- ChildSubType
- CounterAdapter
- Heffalump
- Kernel
- LazyArray
- Object
- OtherComparison
- Pathname
- SubType
- Symbol

No matching classes.

# DataMapper::Spec::Adapters::Adapter

### Attributes

name[R]

### Public Class Methods

new(name) click to toggle source

    # File lib/dm-core/spec/setup.rb, line 95
    def initialize(name)
      @name = name.to_sym
    end

### Public Instance Methods

adapter() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 99
    def adapter
      @adapter ||= setup!
    end

Also aliased as: setup
adapter_name() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 113
    def adapter_name
      @adapter_name ||= infer_adapter_name
    end

alternate_storage_name() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 131
    def alternate_storage_name
      "datamapper_alternate_tests"
    end

connection_uri() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 117
    def connection_uri
      "#{adapter_name}://#{username}%s@#{host}/#{storage_name}".tap do |s|
        return s % ((password.empty?) ? "" : ":#{password}")
      end
    end

default_storage_name() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 127
    def default_storage_name
      "datamapper_default_tests"
    end

host() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 143
    def host
      ENV.fetch('DM_DB_HOST', 'localhost')
    end

password() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 139
    def password
      ENV.fetch('DM_DB_PASSWORD', 'datamapper')
    end

setup() click to toggle source
Alias for: adapter
setup!() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 105
    def setup!
      adapter = DataMapper.setup(name, connection_uri)
      test_connection(adapter)
      adapter
    rescue Exception => e
      puts "Could not connect to the database using '#{connection_uri}' because of: #{e.inspect}"
    end

storage_name() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 123
    def storage_name
      send("#{name}_storage_name")
    end

test_connection(adapter) click to toggle source

Test the connection

Overwrite this method if you need to perform custom connection testing

@raise [Exception]

    # File lib/dm-core/spec/setup.rb, line 152
    def test_connection(adapter)
      if adapter.respond_to?(:select)
        adapter.select('SELECT 1')
      end
    end

username() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 135
    def username
      ENV.fetch('DM_DB_USER', 'datamapper')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.