Class: Sensu::Extension::Base
- Inherits:
-
Object
- Object
- Sensu::Extension::Base
- Defined in:
- lib/sensu/extensions.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #definition ⇒ Object
- #description ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #post_init ⇒ Object
- #run(data = nil, &block) ⇒ Object
- #safe_run(data = nil, &block) ⇒ Object
- #stop(&block) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
100 101 102 103 104 |
# File 'lib/sensu/extensions.rb', line 100 def initialize EM::next_tick do post_init end end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
98 99 100 |
# File 'lib/sensu/extensions.rb', line 98 def settings @settings end |
Class Method Details
.descendants ⇒ Object
149 150 151 152 153 |
# File 'lib/sensu/extensions.rb', line 149 def self.descendants ObjectSpace.each_object(Class).select do |klass| klass < self end end |
Instance Method Details
#[](key) ⇒ Object
133 134 135 |
# File 'lib/sensu/extensions.rb', line 133 def [](key) definition[key.to_sym] end |
#definition ⇒ Object
114 115 116 117 118 119 |
# File 'lib/sensu/extensions.rb', line 114 def definition { :type => 'extension', :name => name } end |
#description ⇒ Object
110 111 112 |
# File 'lib/sensu/extensions.rb', line 110 def description 'extension description (change me)' end |
#has_key?(key) ⇒ Boolean
137 138 139 |
# File 'lib/sensu/extensions.rb', line 137 def has_key?(key) definition.has_key?(key.to_sym) end |
#name ⇒ Object
106 107 108 |
# File 'lib/sensu/extensions.rb', line 106 def name 'base' end |
#post_init ⇒ Object
121 122 123 |
# File 'lib/sensu/extensions.rb', line 121 def post_init true end |
#run(data = nil, &block) ⇒ Object
125 126 127 |
# File 'lib/sensu/extensions.rb', line 125 def run(data=nil, &block) block.call('noop', 0) end |
#safe_run(data = nil, &block) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/sensu/extensions.rb', line 141 def safe_run(data=nil, &block) begin data ? run(data.dup, &block) : run(&block) rescue => error block.call(error.to_s, 2) end end |
#stop(&block) ⇒ Object
129 130 131 |
# File 'lib/sensu/extensions.rb', line 129 def stop(&block) block.call end |