Class: DataChecks::Check
- Inherits:
-
Object
- Object
- DataChecks::Check
- Defined in:
- lib/data_checks/check.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #check_run ⇒ Object
-
#initialize(name, options, block) ⇒ Check
constructor
A new instance of Check.
- #notifiers ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(name, options, block) ⇒ Check
Returns a new instance of Check.
7 8 9 10 11 12 |
# File 'lib/data_checks/check.rb', line 7 def initialize(name, , block) @name = name.to_s @options = @tag = [:tag]&.to_s @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/data_checks/check.rb', line 5 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/data_checks/check.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/data_checks/check.rb', line 5 def @options end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/data_checks/check.rb', line 5 def tag @tag end |
Instance Method Details
#check_run ⇒ Object
22 23 24 |
# File 'lib/data_checks/check.rb', line 22 def check_run @check_run ||= CheckRun.find_by(name: name) end |
#notifiers ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/data_checks/check.rb', line 26 def notifiers configured_notifiers = DataChecks.config. notifiers = Array([:notify] || configured_notifiers.keys).map(&:to_s) notifiers.map do |notifier| raise "Unknown notifier: '#{notifier}'" unless configured_notifiers.key?(notifier) type = configured_notifiers[notifier][:type] klass = Notifiers.lookup(type) klass.new(configured_notifiers[notifier]) end end |
#run ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/data_checks/check.rb', line 14 def run result = block.call rescue Exception => e # rubocop:disable Lint/RescueException error_result(e) else handle_result(result) end |