Sha256: 4a7f7778c4601836133316b98dc43dc4cbdd34548352478d89097a86a122026f

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module ActiveMocker

  module Config
    extend self

    attr_accessor :schema_file,
                  :model_dir,
                  :active_hash_as_base,
                  :schema_attributes,
                  :model_relationships,
                  :model_methods,
                  :mass_assignment,
                  :schema_file_reader,
                  :model_file_reader

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

    def reload_default
      @schema_file         = nil
      @model_dir           = nil
      @active_hash_as_base = false
      @schema_attributes   = true
      @model_relationships = true
      @model_methods       = true
      @mass_assignment     = true
      @log_level           = Logger::WARN
    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?
    end

    def log_level=(level)
      Logger_.level = level
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_mocker-1.0.1 lib/active_mocker/config.rb
active_mocker-1.0.0 lib/active_mocker/config.rb