Nenhuma Descrição http://j1x-huginn.herokuapp.com

twitter_concern.rb 903B

1234567891011121314151617181920212223242526272829
  1. module TwitterConcern
  2. extend ActiveSupport::Concern
  3. included do
  4. self.validate :validate_twitter_options
  5. self.after_initialize :configure_twitter
  6. end
  7. def validate_twitter_options
  8. unless options[:consumer_key].present? &&
  9. options[:consumer_secret].present? &&
  10. options[:oauth_token].present? &&
  11. options[:oauth_token_secret].present?
  12. errors.add(:base, "consumer_key, consumer_secret, oauth_token and oauth_token_secret are required to authenticate with the Twitter API")
  13. end
  14. end
  15. def configure_twitter
  16. Twitter.configure do |config|
  17. config.consumer_key = options[:consumer_key]
  18. config.consumer_secret = options[:consumer_secret]
  19. config.oauth_token = options[:oauth_token] || options[:access_key]
  20. config.oauth_token_secret = options[:oauth_token_secret] || options[:access_secret]
  21. end
  22. end
  23. module ClassMethods
  24. end
  25. end