Sha256: 79616e28a6bc2dead4bc2db3bdd97fce0f0514ffa201ce9c7669999d6c94b4ed

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'forwardable'
require 'luna_park/extensions/injector'
require 'cyclone_lariat/core'
require 'cyclone_lariat/repo/sequel/versions'
require 'cyclone_lariat/repo/active_record/versions'

module CycloneLariat
  module Repo
    class Versions
      include LunaPark::Extensions::Injector

      attr_reader :config

      dependency(:sequel_versions_class) { Repo::Sequel::Versions }
      dependency(:active_record_versions_class) { Repo::ActiveRecord::Versions }

      extend Forwardable

      def_delegators :driver, :add, :remove, :all

      def initialize(**options)
        @config = CycloneLariat::Options.wrap(options).merge!(CycloneLariat.config)
      end

      def driver
        @driver ||= select(driver: config.driver)
      end

      private

      def select(driver:)
        case driver
        when :sequel then sequel_versions_class.new(config.versions_dataset)
        when :active_record then active_record_versions_class.new(config.versions_dataset)
        else raise ArgumentError, "Undefined driver `#{driver}`"
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cyclone_lariat-1.0.0 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc9 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc8 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc7 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc6 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc5 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc4 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc3 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc2 lib/cyclone_lariat/repo/versions.rb
cyclone_lariat-1.0.0.rc1 lib/cyclone_lariat/repo/versions.rb