Sha256: 062bf19535124b94465440f41af00791ed63a623186cd09ff8892785a12dffd4

Contents?: true

Size: 950 Bytes

Versions: 4

Compression:

Stored size: 950 Bytes

Contents

module Twitter
  module Rails
    class << self
      def load_configuration(twitter_yaml_file)
        twitter_yaml_file = ::Rails.root + 'config' + 'twitter.yml'

        if File.exists?(twitter_yaml_file)
          twitter_config = YAML.load(File.read(twitter_yaml_file))[RAILS_ENV]
          ENV['TWITTER_CONSUMER_TOKEN'] = twitter_config['token']
          ENV['TWITTER_CONSUMER_SECRET'] = twitter_config['secret']
        end
      end
    end
  end
end

class ActionController::Base
  class << self
    def inherited_with_twitter(subclass)
      inherited_without_twitter(subclass)
      if subclass.to_s == "ApplicationController"
        subclass.class_eval do
          include Twitter::Rails::Controller
          helper Twitter::Rails::Helpers
        end
      end
    end    
    alias_method_chain :inherited, :twitter
  end
end

twitter_config = Rails.root + 'config' + 'twitter.yml'
Twitter::Rails.load_configuration(twitter_config)

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
szimek-twitter-0.6.4 lib/twitter/rails/initializer.rb
szimek-twitter-0.6.5 lib/twitter/rails/initializer.rb
szimek-twitter_rails-0.0.3 lib/twitter/rails/initializer.rb
szimek-twitter_rails-0.0.4 lib/twitter/rails/initializer.rb