Module: ActiveData::Model::Collectionizable::Proxy

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_data/model/collectionizable/proxy.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
23
24
# File 'lib/active_data/model/collectionizable/proxy.rb', line 20

def method_missing method, *args, &block
  result = with_scope { collectible.send(method, *args, &block) }
  result = self.class.new result if result.instance_of? self.class.superclass
  result
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:



16
17
18
# File 'lib/active_data/model/collectionizable/proxy.rb', line 16

def respond_to? method
  super || collectible.respond_to?(method)
end

#with_scopeObject



26
27
28
29
30
31
32
# File 'lib/active_data/model/collectionizable/proxy.rb', line 26

def with_scope
  previous_scope = collectible.current_scope
  collectible.current_scope = self
  result = yield
  collectible.current_scope = previous_scope
  result
end