Module: Correlate::Relationships

Defined in:
lib/correlate/relationships.rb,
lib/correlate/relationships/couchrest.rb,
lib/correlate/relationships/active_record.rb,
lib/correlate/relationships/active_record/collection_proxy.rb

Defined Under Namespace

Classes: ActiveRecord, CouchRest

Class Method Summary collapse

Class Method Details

.build_correlation(name, type, opts) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/correlate/relationships.rb', line 19

def build_correlation( name, type, opts )
  correlation = Correlation.new
  correlation.name = name
  correlation.type = type
  correlation.target = opts[:class]
  correlation.source = opts[:source]
  correlation.rel = opts[:rel]
  correlation.id_method = opts[:id_method]
  correlation.requires = opts[:requires]
  correlation.required = opts[:required]

  correlation
end

.configure!(klass, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/correlate/relationships.rb', line 9

def configure!( klass, &block )
  if klass.ancestors.include?( ::CouchRest::ExtendedDocument )
    Correlate::Relationships::CouchRest.configure! klass, &block
  else
    if defined?( ::ActiveRecord ) && klass.ancestors.include?( ::ActiveRecord::Base )
      Correlate::Relationships::ActiveRecord.configure! klass, &block
    end
  end
end