Module: Aqua

Aqua

Public Visibility

Public Class Method Summary

include_engine(str)

Loads an external engine from a hash of options.

load_internal_engine(str)

Loads an internal engine from a string.

set_storage_engine(engine) set_storage_engine(engine_details)

Loads the requested backend storage engine.

Returns: TrueClass

Public Class Method Details

include_engine

public include_engine(str)

Loads an external engine from a hash of options.

Meta Tags

See Also:

for the public method that uses this internally
[View source]


89
90
91
92
93
# File 'lib/aqua.rb', line 89

def self.include_engine( str )
  Aqua::Storage.class_eval do
    include str.constantize
  end
end

load_internal_engine

public load_internal_engine(str)

Loads an internal engine from a string

Meta Tags

[View source]


80
81
82
83
84
# File 'lib/aqua.rb', line 80

def self.load_internal_engine( str )
  underscored = str.underscore
  require "aqua/store/#{underscored}/#{underscored}"
  include_engine( "Aqua::Store::#{str}::StorageMethods" )
end

set_storage_engine

public set_storage_engine(engine)
public set_storage_engine(engine_details)

Loads the requested backend storage engine. Used early on in configuration. If not declared in configuration, will be called automatically with default engine, at runtime, when needed.

Meta Tags

Examples

Internal library loading from a string
  Aqua.set_storage_engine( "CouchDB" )
External library loading from a gem. :module argument is the gem's module responsible for implementing the storage methods
  Aqua.set_storage_engine( :require => 'my_own/storage_gem', :module => 'MyOwn::StorageGem::StorageMethods' )
External library loading from a non-gem external library.
  Aqua.set_storage_engine( :require => '/absolute/path/to/library', :module => 'My::StorageLib::StorageMethods' )

Returns:

[TrueClass]

when successful.

Raises:

[ArgumentError]

when argument is neither a Hash nor a String.

Overloads

public set_storage_engine(engine)

Loads an Aqua internal library.

Meta Tags

public set_storage_engine(engine_details)

Loads any engine provided a path to the self-loading library and the module full name

Meta Tags

Parameters:

Options Hash engine_details
Key Name Default Value Accepted Types Description
:require N/A [String]

The path or gem name used in a require statement

:module N/A [String]

String with the full module name

[View source]


64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/aqua.rb', line 64

def self.set_storage_engine( engine="CouchDB" ) 
  if engine.class == String
    load_internal_engine( engine )
    true
  elsif engine.class == Hash
    engine = Mash.new( engine )
    require engine[:require]
    include_engine( engine[:module] )
    true
  else
    raise ArgumentError, 'engine must be a string relating to an internal Aqua library store, or a hash of values indicating where to find the external library'
  end      
end
Generated on Thursday, August 27 2009 at 05:50:25 PM by YARD 0.2.3.5 (ruby-1.8.6).