Class: Feedbook::Notifiers::TwitterNotifier
- Inherits:
-
Object
- Object
- Feedbook::Notifiers::TwitterNotifier
- Includes:
- Singleton
- Defined in:
- lib/feedbook/notifiers/twitter_notifier.rb
Instance Method Summary collapse
-
#load_configuration(configuration = {}) ⇒ NilClass
Load configuration for TwitterNotifier.
-
#notify(message) ⇒ NilClass
Sends notification to Twitter.
Instance Method Details
#load_configuration(configuration = {}) ⇒ NilClass
Load configuration for TwitterNotifier
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/feedbook/notifiers/twitter_notifier.rb', line 31 def load_configuration(configuration = {}) @client = Twitter::REST::Client.new do |config| config.consumer_key = configuration.fetch('api_key') config.consumer_secret = configuration.fetch('api_secret') config.access_token = configuration.fetch('access_token') config.access_token_secret = configuration.fetch('access_token_secret') end puts 'Configuration loaded for TwitterNotifier' rescue Twitter::Error => e raise Errors::NotifierConfigurationError.new(:twitter, e.) end |
#notify(message) ⇒ NilClass
Sends notification to Twitter
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/feedbook/notifiers/twitter_notifier.rb', line 15 def notify() if client.nil? puts "Message has not been notified on Twitter: #{} because of invalid client configuration" else client.update() puts "New message has been notified on Twitter: #{}" end rescue Twitter::Error => e p "TwitterNotifier did not notify because of client error (#{e.})." end |