Class: Lolita::Adapter::Mongoid::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/lolita/adapter/mongoid.rb

Overview

Association adapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assoc_object, adapter) ⇒ Association

Returns a new instance of Association.



17
18
19
20
# File 'lib/lolita/adapter/mongoid.rb', line 17

def initialize(assoc_object,adapter)
  @association = assoc_object
  @adapter = adapter
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



22
23
24
# File 'lib/lolita/adapter/mongoid.rb', line 22

def method_missing(method, *args, &block)
  @association.send(method,*args,&block)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



15
16
17
# File 'lib/lolita/adapter/mongoid.rb', line 15

def adapter
  @adapter
end

#associationObject (readonly)

Returns the value of attribute association.



15
16
17
# File 'lib/lolita/adapter/mongoid.rb', line 15

def association
  @association
end

Instance Method Details

#keyObject



26
27
28
# File 'lib/lolita/adapter/mongoid.rb', line 26

def key
  @association.foreign_key
end

#macroObject



42
43
44
45
46
47
48
# File 'lib/lolita/adapter/mongoid.rb', line 42

def macro
  convertator = {
    :has_many => :many, :belongs_to => :one, :has_one => :one,
    :has_and_belongs_to_many => :many_to_many, :embeds_one => :one, :embeds_many => :many
  }
  convertator[@association.macro]
end

#native_macroObject



38
39
40
# File 'lib/lolita/adapter/mongoid.rb', line 38

def native_macro
  @association.macro
end

#throughObject



34
35
36
# File 'lib/lolita/adapter/mongoid.rb', line 34

def through
  nil
end

#through?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/lolita/adapter/mongoid.rb', line 30

def through?
  false
end