module Pagy::CalendarExtra::BackendAddOn

def pagy_calendar(collection, conf)

Take a collection and a conf Hash with keys in CONF_KEYS and return an array with 3 items: [calendar, pagy, results]
def pagy_calendar(collection, conf)
  raise ArgumentError, "keys must be in #{CONF_KEYS.inspect}" \
        unless conf.is_a?(Hash) && (conf.keys - CONF_KEYS).empty?
  conf[:pagy] ||= {}
  unless conf.key?(:active) && !conf[:active]
    calendar, from, to = Calendar.send(:init, conf, pagy_calendar_period(collection), params)
    if respond_to?(:pagy_calendar_counts)
      calendar.each_key do |unit|
        calendar[unit].vars[:counts] = pagy_calendar_counts(collection, unit, *calendar[unit].vars[:period])
      end
    end
    collection = pagy_calendar_filter(collection, from, to)
  end
  pagy, results = send(conf[:pagy][:backend] || :pagy, collection, **conf[:pagy])  # use backend: :pagy when omitted
  [calendar, pagy, results]
end

def pagy_calendar_filter(*)

This method must be implemented by the application
def pagy_calendar_filter(*)
  raise NoMethodError, 'the pagy_calendar_filter method must be implemented by the application ' \
                       '(see https://ddnexus.github.io/pagy/docs/extras/calendar/#pagy-calendar-filter-collection-from-to)'
end

def pagy_calendar_period(*)

This method must be implemented by the application
def pagy_calendar_period(*)
  raise NoMethodError, 'the pagy_calendar_period method must be implemented by the application ' \
                       '(see https://ddnexus.github.io/pagy/docs/extras/calendar/#pagy-calendar-period-collection)'
end