Class: Egg::Notifier
- Inherits:
-
Object
- Object
- Egg::Notifier
- Defined in:
- lib/egg-notifier/version.rb,
lib/egg-notifier/egg/notifier.rb,
lib/egg-notifier/egg/exceptions.rb
Defined Under Namespace
Classes: HTTPFailure
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#event_name ⇒ Object
Returns the value of attribute event_name.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(event_name, timestamp = Time.now) ⇒ Notifier
constructor
A new instance of Notifier.
Constructor Details
#initialize(event_name, timestamp = Time.now) ⇒ Notifier
Returns a new instance of Notifier.
8 9 10 11 12 13 |
# File 'lib/egg-notifier/egg/notifier.rb', line 8 def initialize(event_name, =Time.now) @event_name = event_name = Time.parse(.to_s) unless .respond_to?(:utc) @timestamp = .utc.iso8601 end |
Instance Attribute Details
#event_name ⇒ Object
Returns the value of attribute event_name.
6 7 8 |
# File 'lib/egg-notifier/egg/notifier.rb', line 6 def event_name @event_name end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/egg-notifier/egg/notifier.rb', line 6 def @timestamp end |
Instance Method Details
#execute! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/egg-notifier/egg/notifier.rb', line 15 def execute! raise APIKeyNotDefined unless Egg.api_key raise UrlNotDefined unless Egg.url response = self.class.http.post(url.path, params.to_json, headers) if Egg.raise_on_failure and !response.kind_of?(Net::HTTPSuccess) if response raise HTTPFailure.new("#{response.code}: #{response.body}") else raise HTTPFailure.new("nil HTTP response, that's odd.") end end response end |