Sha256: fe39cebb51487b8c02b52086cfc86522f7e5a5f1b043a0569d7c10e0dc313fe2

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 KB

Contents

module ActiveMocker

  module Config
    extend self

    attr_accessor :schema_file,
                  :model_dir,
                  :schema_attributes,
                  :model_attributes,
                  :schema_file_reader,
                  :model_file_reader,
                  :clear_cache,
                  :migration_dir,
                  :mock_dir,
                  :logger,
                  :log_level

    def config
      @@first_load ||= reload_default
      yield self
      check_required_settings
    end

    def reload_default
      @schema_file         = nil
      @model_dir           = nil
      @schema_attributes   = true
      @model_attributes    = true
      @clear_cache         = false
      @schema_file_reader  = nil
      @model_file_reader   = nil
      @migration_dir       = nil
      @mock_dir            = nil
      @logger              = ::Logger.new(STDOUT)
    end

    def check_required_settings
      raise 'schema_file must be specified' if schema_file.nil?
      raise 'model_dir must be specified'   if model_dir.nil?
      raise 'mock_dir must be specified'    if mock_dir.nil?
    end

    def logger=(logger)
      @logger = logger
      Logger.set(logger)
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_mocker-1.6.4 lib/active_mocker/config.rb
active_mocker-1.6.3 lib/active_mocker/config.rb
active_mocker-1.6.2 lib/active_mocker/config.rb
active_mocker-1.6.1 lib/active_mocker/config.rb
active_mocker-1.6 lib/active_mocker/config.rb
active_mocker-1.5.2 lib/active_mocker/config.rb
active_mocker-1.5.1 lib/active_mocker/config.rb
active_mocker-1.5 lib/active_mocker/config.rb
active_mocker-1.4.2 lib/active_mocker/config.rb
active_mocker-1.4.1 lib/active_mocker/config.rb
active_mocker-1.3.2 lib/active_mocker/config.rb
active_mocker-1.3.1 lib/active_mocker/config.rb
active_mocker-1.3 lib/active_mocker/config.rb
active_mocker-1.2.4 lib/active_mocker/config.rb
active_mocker-1.2.3 lib/active_mocker/config.rb