Sha256: b46a74866ec6289c2e8a702141dbfc1f90b5972bfd5baf0fa68757406fef922b

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

require 'logger'
require 'active_support/core_ext/module/attribute_accessors'
require 'sn_foil/context'
require 'sn_foil/policy'
require 'sn_foil/searcher'
require 'sn_foil/version'

module SnFoil
  class Error < StandardError; end

  mattr_accessor :orm, default: 'active_record'
  mattr_writer :logger

  class << self
    def logger
      @logger ||= Logger.new($stdout).tap do |log|
        log.progname = name
      end
    end

    def adapter
      return @adapter if @adapter

      @adapter ||= if orm.instance_of?(String) || orm.instance_of?(Symbol)
                     if Object.const_defined?("SnFoil::Adapters::ORMs::#{orm.camelcase}")
                       "SnFoil::Adapters::ORMs::#{orm.camelcase}".constantize
                     else
                       orm.constantize
                     end
                   else
                     orm
                   end
    end

    def configure
      yield self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snfoil-0.1.0 lib/sn_foil.rb