Class: DataChecks::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/data_checks/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
# File 'lib/data_checks/config.rb', line 8

def initialize
  @checks = []
  @notifier_options = {}
end

Instance Attribute Details

#backtrace_cleanerObject

Returns the value of attribute backtrace_cleaner.



6
7
8
# File 'lib/data_checks/config.rb', line 6

def backtrace_cleaner
  @backtrace_cleaner
end

#checksObject (readonly)

Returns the value of attribute checks.



5
6
7
# File 'lib/data_checks/config.rb', line 5

def checks
  @checks
end

#error_handlerObject

Returns the value of attribute error_handler.



6
7
8
# File 'lib/data_checks/config.rb', line 6

def error_handler
  @error_handler
end

#notifier_optionsObject (readonly)

Returns the value of attribute notifier_options.



5
6
7
# File 'lib/data_checks/config.rb', line 5

def notifier_options
  @notifier_options
end

Instance Method Details

#ensure_any(name, **options, &block) ⇒ Object



17
18
19
# File 'lib/data_checks/config.rb', line 17

def ensure_any(name, **options, &block)
  add_check(EnsureMore, name, options.merge(than: 0), block)
end

#ensure_equal(name, **options, &block) ⇒ Object



29
30
31
# File 'lib/data_checks/config.rb', line 29

def ensure_equal(name, **options, &block)
  add_check(EnsureEqual, name, options, block)
end

#ensure_less(name, **options, &block) ⇒ Object



25
26
27
# File 'lib/data_checks/config.rb', line 25

def ensure_less(name, **options, &block)
  add_check(EnsureLess, name, options, block)
end

#ensure_more(name, **options, &block) ⇒ Object



21
22
23
# File 'lib/data_checks/config.rb', line 21

def ensure_more(name, **options, &block)
  add_check(EnsureMore, name, options, block)
end

#ensure_no(name, **options, &block) ⇒ Object



13
14
15
# File 'lib/data_checks/config.rb', line 13

def ensure_no(name, **options, &block)
  add_check(EnsureNo, name, options, block)
end

#notifier(name, **options) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/data_checks/config.rb', line 33

def notifier(name, **options)
  name = name.to_s

  if notifier_options.key?(name)
    raise ArgumentError, "Duplicate notifier: '#{name}'"
  else
    options[:type] ||= name
    notifier_options[name] = options
  end
end