Module: CouchRest::Model::Proxyable

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/couchrest/model/proxyable.rb

Overview

:nodoc: Because I like inventing words

Defined Under Namespace

Modules: ClassMethods Classes: ModelProxy

Instance Method Summary collapse

Instance Method Details

#proxy_database(assoc_name) ⇒ Object

Raises:

  • (StandardError)

7
8
9
10
11
12
13
14
15
# File 'lib/couchrest/model/proxyable.rb', line 7

def proxy_database(assoc_name)
  raise StandardError, "Please set the #proxy_database_method" if self.class.proxy_database_method.nil?
  db_name = self.send(self.class.proxy_database_method)
  db_suffix = self.class.proxy_database_suffixes[assoc_name.to_sym]
  @_proxy_databases ||= {}
  @_proxy_databases[assoc_name.to_sym] ||= begin
    self.class.prepare_database([db_name, db_suffix].compact.reject(&:blank?).join(self.class.connection[:join]))
  end
end