Class: CheckZilla::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/checkzilla/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title = "Report", &block) ⇒ Model

Returns a new instance of Model.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/checkzilla/model.rb', line 6

def initialize(title = "Report", &block)
  @title = title
  @checkers = []
  @notifiers = []

  instance_eval(&block) if block_given?

  @checkers.each do |checker|
    checker.perform!
  end

  @notifiers.each do |notifier|
    notifier.perform! @checkers
  end
end

Instance Attribute Details

#checkersObject (readonly)

Returns the value of attribute checkers.



4
5
6
# File 'lib/checkzilla/model.rb', line 4

def checkers
  @checkers
end

#notifiersObject (readonly)

Returns the value of attribute notifiers.



4
5
6
# File 'lib/checkzilla/model.rb', line 4

def notifiers
  @notifiers
end

Instance Method Details

#check_updates(klass, &block) ⇒ Object



22
23
24
# File 'lib/checkzilla/model.rb', line 22

def check_updates klass, &block
  @checkers << CheckZilla::Check.const_get(camelize(klass.to_s)).new(&block)
end

#notify_by(klass, &block) ⇒ Object



26
27
28
# File 'lib/checkzilla/model.rb', line 26

def notify_by klass, &block
  @notifiers << CheckZilla::Notifier.const_get(camelize(klass.to_s)).new(&block)
end