Sha256: 93e9a4709eb1699a722dca9a906e590706909dc1c080198d7fbba7b0edc5c1b0
Contents?: true
Size: 939 Bytes
Versions: 2
Compression:
Stored size: 939 Bytes
Contents
module Enumerable Groupdate::PERIODS.each do |period| define_method :"group_by_#{period}" do |*args, **options, &block| if block raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0)" if args.any? Groupdate::Magic::Enumerable.group_by(self, period, options, &block) elsif respond_to?(:scoping) scoping { klass.group_by_period(period, *args, **options, &block) } else raise ArgumentError, "no block given" end end end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
groupdate-6.5.1 | lib/groupdate/enumerable.rb |
groupdate-6.5.0 | lib/groupdate/enumerable.rb |