Class: Eye::Trigger
- Inherits:
-
Object
- Object
- Eye::Trigger
- Extended by:
- Dsl::Validation
- Includes:
- Logger::Helpers
- Defined in:
- lib/eye/trigger.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Flapping
Constant Summary collapse
- TYPES =
ex: { :type => :flapping, :times => 2, :within => 30.seconds}
{:flapping => "Flapping"}
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes included from Dsl::Validation
#defaults, #should_bes, #validates, #variants
Attributes included from Logger::Helpers
Class Method Summary collapse
- .create(options = {}, logger_prefix = nil) ⇒ Object
- .get_class(type) ⇒ Object
- .validate!(options = {}) ⇒ Object
Instance Method Summary collapse
- #check(states_history) ⇒ Object
- #good? ⇒ Boolean
-
#initialize(options = {}, logger_prefix = nil) ⇒ Trigger
constructor
A new instance of Trigger.
Methods included from Dsl::Validation
Constructor Details
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/eye/trigger.rb', line 10 def @message end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/eye/trigger.rb', line 10 def @options end |
Class Method Details
.create(options = {}, logger_prefix = nil) ⇒ Object
18 19 20 |
# File 'lib/eye/trigger.rb', line 18 def self.create( = {}, logger_prefix = nil) get_class([:type]).new(, logger_prefix) end |
.get_class(type) ⇒ Object
12 13 14 15 16 |
# File 'lib/eye/trigger.rb', line 12 def self.get_class(type) klass = eval("Eye::Trigger::#{TYPES[type]}") rescue nil raise "Unknown trigger #{type}" unless klass klass end |
.validate!(options = {}) ⇒ Object
22 23 24 |
# File 'lib/eye/trigger.rb', line 22 def self.validate!( = {}) get_class([:type]).validate() end |
Instance Method Details
#check(states_history) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eye/trigger.rb', line 33 def check(states_history) @states_history = states_history res = good? if res debug 'check flapping' else debug "!!! #{self.class} recognized !!!" end res end |
#good? ⇒ Boolean
47 48 49 |
# File 'lib/eye/trigger.rb', line 47 def good? raise 'realize me' end |