Sha256: 4b2b6f2a1bcd82a4048fc5453a25d7fbbb87dfa0622713e5cc9d9b7e9accf13e

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require_relative 'sn_foil/version'
require_relative 'sn_foil/contexts/build_context'
require_relative 'sn_foil/contexts/index_context'
require_relative 'sn_foil/contexts/show_context'
require_relative 'sn_foil/contexts/create_context'
require_relative 'sn_foil/contexts/update_context'
require_relative 'sn_foil/contexts/destroy_context'
require_relative 'sn_foil/context'
require_relative 'sn_foil/policy'
require_relative 'sn_foil/searcher'
require 'active_support/core_ext/module/attribute_accessors'
require 'logger'

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

6 entries across 6 versions & 1 rubygems

Version Path
snfoil-0.5.3 lib/sn_foil.rb
snfoil-0.5.0 lib/sn_foil.rb
snfoil-0.4.3 lib/sn_foil.rb
snfoil-0.4.2 lib/sn_foil.rb
snfoil-0.4.1 lib/sn_foil.rb
snfoil-0.4.0 lib/sn_foil.rb