rkrage/pg_party

View on GitHub
lib/pg_party/model/methods.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

require "pg_party/model_injector"

module PgParty
  module Model
    module Methods
      def range_partition_by(*key, &blk)
        PgParty::ModelInjector.new(self, *key, &blk).inject_range_methods
      end

      def list_partition_by(*key, &blk)
        PgParty::ModelInjector.new(self, *key, &blk).inject_list_methods
      end

      def hash_partition_by(*key, &blk)
        PgParty::ModelInjector.new(self, *key, &blk).inject_hash_methods
      end

      def partitioned?
        try(:partition_key).present?
      end
    end
  end
end