Method: ReactiveRecord::Collection#method_missing

Defined in:
lib/reactive_record/active_record/reactive_record/collection.rb

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



523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/reactive_record/active_record/reactive_record/collection.rb', line 523

def method_missing(method, *args, &block)
  if [].respond_to? method
    all.send(method, *args, &block)
  elsif ScopeDescription.find(@target_klass, method)
    apply_scope(method, *args)
  elsif args.count == 1 && method.start_with?('find_by_')
    apply_scope(:find_by, method.sub(/^find_by_/, '') => args.first)
  elsif @target_klass.respond_to?(method) && ScopeDescription.find(@target_klass, "_#{method}")
    apply_scope("_#{method}", *args).first
  else
    super
  end
end