Module: Ambry

Extended by:
Ambry
Included in:
Ambry
Defined in:
lib/ambry.rb,
lib/ambry/model.rb,
lib/ambry/mapper.rb,
lib/ambry/adapter.rb,
lib/ambry/version.rb,
lib/ambry/hash_proxy.rb,
lib/ambry/active_model.rb,
lib/ambry/adapters/file.rb,
lib/ambry/adapters/yaml.rb,
lib/ambry/adapters/cookie.rb,
lib/ambry/abstract_key_set.rb

Overview

Ambry is a database and ORM replacement for small, mostly static models.

Ambry is free software released under the terms of the MIT License.

Author:

Defined Under Namespace

Modules: ActiveModel, Adapters, Model, Version Classes: AbstractKeySet, Adapter, AmbryError, HashProxy, HashProxySet, KeyIterator, Mapper, NotFoundError

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) adapters (readonly)

A hash of all instantiated Ambry adapters.



24
25
26
# File 'lib/ambry.rb', line 24

def adapters
  @adapters
end

- (Object) default_adapter_name (readonly)

The default adapter name.



20
21
22
# File 'lib/ambry.rb', line 20

def default_adapter_name
  @default_adapter_name
end

Instance Method Details

- (Object) register_adapter(adapter)

Registers an adapter with Ambry. This facilitates allowing models to specify an adapter by name rather than class or instance.



32
33
34
35
36
37
38
39
40
# File 'lib/ambry.rb', line 32

def register_adapter(adapter)
  name = adapter.name.to_sym
  if adapters[name]
    raise AmbryError, "Adapter #{name.inspect} already registered"
  end
  @lock.synchronize do
    adapters[name] = adapter
  end
end