Class: MongoModel::Associations::Base::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/concerns/associations/base/proxy.rb

Direct Known Subclasses

HasManyByForeignKey::Proxy, HasManyByIds::Proxy

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Proxy) initialize(association)



12
13
14
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 12

def initialize(association)
  @association = association
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(*args, &block) (private)



45
46
47
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 45

def method_missing(*args, &block)
  target.send(*args, &block)
end

Instance Attribute Details

- (Object) association (readonly)

Returns the value of attribute association



10
11
12
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 10

def association
  @association
end

Instance Method Details

- (Object) loaded!



31
32
33
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 31

def loaded!
  @loaded = true
end

- (Boolean) loaded?



27
28
29
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 27

def loaded?
  @loaded
end

- (Object) proxy_respond_to?



5
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 5

alias_method :proxy_respond_to?, :respond_to?

- (Object) reset



35
36
37
38
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 35

def reset
  @loaded = false
  @target = nil
end

- (Boolean) respond_to?(*args)



40
41
42
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 40

def respond_to?(*args)
  proxy_respond_to?(*args) || target.respond_to?(*args)
end

- (Object) target



22
23
24
25
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 22

def target
  load_target
  @target
end

- (Object) target=(new_target)



16
17
18
19
20
# File 'lib/mongomodel/concerns/associations/base/proxy.rb', line 16

def target=(new_target)
  @target = new_target
  loaded!
  @target
end