Sha256: 222abc2479983dadbaf60d95cf33862f9c14d9167ba97f2fec809dbc91416d05
Contents?: true
Size: 809 Bytes
Versions: 8
Compression:
Stored size: 809 Bytes
Contents
module Groupdate module QueryMethods Groupdate::PERIODS.each do |period| define_method :"group_by_#{period}" do |field, time_zone = nil, range = nil, **options| Groupdate::Magic::Relation.generate_relation(self, period: period, field: field, time_zone: time_zone, range: range, **options ) end end def group_by_period(period, field, permit: nil, **options) # to_sym is unsafe on user input, so convert to strings permitted_periods = ((permit || Groupdate::PERIODS).map(&:to_sym) & Groupdate::PERIODS).map(&:to_s) if permitted_periods.include?(period.to_s) send("group_by_#{period}", field, **options) else raise ArgumentError, "Unpermitted period" end end end end
Version data entries
8 entries across 8 versions & 2 rubygems