<commit_before>module ROM
  module SQL
    module Plugin
      module Pagination
        class Pager
          include Options

          option :current_page, reader: true
          option :per_page, reader: true

          attr_reader :dataset
          attr_reader :current_page

          def initialize(dataset, options = {})
            @dataset = dataset
            super
          end

          def next_page
            num = current_page + 1
            num if total_pages >= num
          end

          def prev_page
            num = current_page - 1
            num if num > 0
          end

          def total
            dataset.unlimited.count
          end

          def total_pages
            (total / per_page) + 1
          end
        end

        def self.included(klass)
          klass.defines :per_page
        end

        attr_reader :pager

        def initialize(dataset, registry, current_page = nil)
          super(dataset, registry)
          @pager = Pager.new(
            dataset, current_page: current_page, per_page: self.class.per_page
          )
        end

        def page(num)
          per_page = self.class.per_page
          paginated = dataset.offset((num-1)*per_page).limit(per_page)
          self.class.new(paginated, __registry__, num)
        end
      end
    end
  end
end<commit_msg>Update pagination plugin to use option API<commit_after>module ROM
  module SQL
    module Plugin
      module Pagination
        class Pager
          include Options

          option :current_page, reader: true
          option :per_page, reader: true

          attr_reader :dataset
          attr_reader :current_page

          def initialize(dataset, options = {})
            @dataset = dataset
            super
          end

          def next_page
            num = current_page + 1
            num if total_pages >= num
          end

          def prev_page
            num = current_page - 1
            num if num > 0
          end

          def total
            dataset.unlimited.count
          end

          def total_pages
            (total / per_page) + 1
          end
        end

        def self.included(klass)
          klass.defines :per_page
          klass.option :current_page
        end

        attr_reader :pager

        def initialize(dataset, options = {})
          super
          @pager = Pager.new(
            dataset,
            current_page: options[:current_page],
            per_page: self.class.per_page
          )
        end

        def page(num)
          per_page = self.class.per_page
          paginated = dataset.offset((num-1)*per_page).limit(per_page)
          self.class.new(paginated, current_page: num)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.058396808124773304, 'fraction_numerical': 0.003627130939426913, 'mean_word_length': 1.3572649572649573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2741173', 'n_tokens_mistral': 748, 'n_tokens_neox': 717, 'n_words': 200}