Sha256: 3a9b8376b294718b8209c8ca34ea509b3c10cdc3dddeb96862376b9fcc8d18d3

Contents?: true

Size: 865 Bytes

Versions: 10

Compression:

Stored size: 865 Bytes

Contents

require 'annex/engine'
require 'annex/config'
require 'annex/extension'
require 'annex/extensions/cancan'
require 'annex/railtie'

module Annex
  # Configuration defaults
  @config = {
    adapter: :activerecord
  }

  @valid_config_keys = @config.keys

  # Configure through hash
  def self.configure(opts = {})
    opts.each { |k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
  end

  # Configure through yaml file
  def self.configure_with(path_to_yaml_file)
    begin
      config = YAML::load(IO.read(path_to_yaml_file))
    rescue Errno::ENOENT
      log(:warning, "YAML configuration file couldn't be found. Using defaults."); return
    rescue Psych::SyntaxError
      log(:warning, "YAML configuration file contains invalid syntax. Using defaults."); return
    end

    configure(config)
  end

  def self.config
    @config
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
annex-cms-0.5.0 lib/annex-cms.rb
annex-cms-0.4.0 lib/annex-cms.rb
annex-cms-0.3.8 lib/annex-cms.rb
annex-cms-0.3.7 lib/annex-cms.rb
annex-cms-0.3.6 lib/annex-cms.rb
annex-cms-0.3.5 lib/annex-cms.rb
annex-cms-0.3.4 lib/annex-cms.rb
annex-cms-0.3.2 lib/annex-cms.rb
annex-cms-0.3.1 lib/annex-cms.rb
annex-cms-0.3.0 lib/annex-cms.rb