Sha256: bc153f2c1a0a685ad31aef9f7a32ec45c8e56c50912bf6e39cdbc20334807820
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require "clowne/version" require "clowne/declarations" require "clowne/cloner" require "clowne/adapters/base" # Declarative models cloning module Clowne # List of built-in adapters # rubocop:disable Layout/AlignHash ADAPTERS = { base: "Base", active_record: "ActiveRecord", sequel: "Sequel", }.freeze # rubocop:enable Layout/AlignHash class << self attr_reader :default_adapter, :raise_on_override # Set default adapters for all cloners def default_adapter=(adapter) @default_adapter = resolve_adapter(adapter) end def resolve_adapter(adapter) if adapter.is_a?(Class) adapter.new elsif adapter.is_a?(Symbol) adapter_class = ADAPTERS[adapter] raise "Unknown adapter: #{adapter}" if adapter_class.nil? Clowne::Adapters.const_get(adapter_class).new else adapter end end end end require "clowne/adapters/active_record" if defined?(::ActiveRecord) require "clowne/adapters/sequel" if defined?(::Sequel)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.3.0 | lib/clowne.rb |
clowne-1.2.0 | lib/clowne.rb |