Module: Draper::QueryMethods

Included in:
CollectionDecorator
Defined in:
lib/draper/query_methods.rb,
lib/draper/query_methods/load_strategy.rb

Defined Under Namespace

Modules: LoadStrategy

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Proxies missing query methods to the source class if the strategy allows.



6
7
8
9
10
# File 'lib/draper/query_methods.rb', line 6

def method_missing(method, *args, &block)
  return super unless strategy.allowed? method

  object.send(method, *args, &block).decorate(with: decorator_class, context: context)
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/draper/query_methods.rb', line 12

def respond_to_missing?(method, include_private = false)
  strategy.allowed?(method) || super
end