module Minidoc::Counters::ClassMethods

Public Instance Methods

counter(field, options = {}) click to toggle source
# File lib/minidoc/counters.rb, line 8
      def counter(field, options = {})
        start = options.fetch(:start, 0)
        step_size = options.fetch(:step_size, 1)

        attribute field, Integer, default: start

        class_eval(<<-EOM)
          def increment_#{field}
            Minidoc::Counters::Incrementor.
              new(self, :#{field}).increment(#{step_size})
          end
        EOM
      end