Module: Enumerable

Defined in:
lib/groupdate/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#group_by_period(period, *args, **options, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/groupdate/enumerable.rb', line 15

def group_by_period(period, *args, **options, &block)
  if block || !respond_to?(:scoping)
    raise ArgumentError, "wrong number of arguments (given #{args.size + 1}, expected 1)" if args.any?

    Groupdate::Magic.validate_period(period, options.delete(:permit))
    send("group_by_#{period}", **options, &block)
  else
    scoping { @klass.group_by_period(period, *args, **options, &block) }
  end
end