Sha256: 7637025c085a0bcedddf18431e57644150e278dd1851ed820c634f52ad84ea38

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 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_relative 'sn_foil/adapters/orms/base_adapter'
require_relative 'sn_foil/adapters/orms/active_record'
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

11 entries across 11 versions & 1 rubygems

Version Path
snfoil-0.9.0 lib/sn_foil.rb
snfoil-0.8.5 lib/sn_foil.rb
snfoil-0.8.4 lib/sn_foil.rb
snfoil-0.8.3 lib/sn_foil.rb
snfoil-0.8.2 lib/sn_foil.rb
snfoil-0.8.1 lib/sn_foil.rb
snfoil-0.8.0 lib/sn_foil.rb
snfoil-0.7.0 lib/sn_foil.rb
snfoil-0.6 lib/sn_foil.rb
snfoil-0.5.5 lib/sn_foil.rb
snfoil-0.5.4 lib/sn_foil.rb