lib/em-twitter/client.rb in em-twitter-0.1.1 vs lib/em-twitter/client.rb in em-twitter-0.1.2

- old
+ new

@@ -14,11 +14,12 @@ :too_long_callback, :range_unacceptable_callback, :enhance_your_calm_callback, :reconnect_callback, :max_reconnects_callback, - :close_callback + :close_callback, + :no_data_callback ].freeze unless defined?(CALLBACKS) attr_accessor :connection, :options, :host, :port attr_accessor *CALLBACKS @@ -30,10 +31,12 @@ end def initialize(options = {}) @options = DEFAULT_CONNECTION_OPTIONS.merge(options) + validate_client + @host = @options[:host] @port = @options[:port] if @options[:proxy] && @options[:proxy][:uri] proxy_uri = URI.parse(@options[:proxy][:uri]) @@ -94,17 +97,29 @@ def on_close(&block) @close_callback = block end + def on_no_data_received(&block) + @no_data_callback = block + end + # Delegate to EM::Twitter::Connection def method_missing(method, *args, &block) return super unless @connection.respond_to?(method) @connection.send(method, *args, &block) end def respond_to?(method, include_private=false) @connection.respond_to?(method, include_private) || super(method, include_private) + end + + private + + def validate_client + if @options[:oauth] && @options[:basic] + raise ConfigurationError.new('Client cannot be configured for both OAuth and Basic Auth') if !@options[:oauth].empty? && !@options[:basic].empty? + end end end end end \ No newline at end of file