Sha256: bff7df59b590f4d72b0f48900311da4fd6eadfb5c5b08bed93127520c06d0a77

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module Upgrow
  # Base class for Repositories. It offers a basic API for the state all
  # Repositories should have, as well as the logic on how to materialize data
  # into Models.
  class BasicRepository
    class << self
      attr_writer :base

      # the base object to be used internally to retrieve the persisted data.
      # For example, a base class in which queries can be performed for a
      # relational database adapter. Defaults to `nil`.
      #
      # @return [Object] the Repository base.
      def base
        @base || default_base
      end

      private

      def default_base; end
    end

    attr_reader :base

    # Sets the Basic Repositorie's state.
    def initialize
      @base = self.class.base
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
upgrow-0.0.5 lib/upgrow/basic_repository.rb
upgrow-0.0.4 lib/upgrow/basic_repository.rb