From f1b42bf82440f2dc0ba61761fc8f12460e20aadf Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Wed, 19 Mar 2014 14:39:02 +0100 Subject: [PATCH] Ensure predicate methods return false for Twitter::NullObject --- README.md | 34 ++++++---------------------------- Rakefile | 2 +- lib/twitter/base.rb | 2 +- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 695ea67a6..0c99a66bc 100644 --- a/README.md +++ b/README.md @@ -153,12 +153,12 @@ end ``` An `object` may be one of the following: -* Twitter::DirectMessage -* Twitter::Streaming::DeletedTweet -* Twitter::Streaming::Event -* Twitter::Streaming::FriendList -* Twitter::Streaming::StallWarning -* Twitter::Tweet +* `Twitter::DirectMessage` +* `Twitter::Streaming::DeletedTweet` +* `Twitter::Streaming::Event` +* `Twitter::Streaming::FriendList` +* `Twitter::Streaming::StallWarning` +* `Twitter::Tweet` ### Cursors The `Twitter::Cursor` class has been completely redesigned with a focus on @@ -388,11 +388,6 @@ at the beginning: * `#saved_search_destroy` is now `#destroy_saved_search` * `#status_destroy` is now `#destroy_status` -### Errors -The `Twitter::Error::ClientError` and `Twitter::Error::ServerError` class -hierarchy has been removed. All errors now inherit directly from -`Twitter::Error`. - ### Null Objects In version 4, methods you would expect to return a `Twitter` object would return `nil` if that object was missing. This may have resulted in a @@ -469,23 +464,6 @@ After configuration, requests can be made like so: client.update("I'm tweeting with @gem!") ``` -### Middleware -The Faraday middleware stack is fully configurable and is exposed as a -`Faraday::RackBuilder` object. You can modify the default middleware in-place: - -```ruby -client.middleware.insert_after Twitter::Response::RaiseError, CustomMiddleware -``` - -A custom adapter may be set as part of a custom middleware stack: - -```ruby -client.middleware = Faraday::RackBuilder.new do |faraday| - # Specify a middleware stack here - faraday.adapter :some_other_adapter -end -``` - ## Usage Examples All examples require an authenticated Twitter client. See the section on configuration. diff --git a/Rakefile b/Rakefile index 09cbf7753..76102cf1e 100644 --- a/Rakefile +++ b/Rakefile @@ -31,7 +31,7 @@ end require 'yardstick/rake/verify' Yardstick::Rake::Verify.new do |verify| - verify.threshold = 59.5 + verify.threshold = 59.4 end task :default => [:spec, :rubocop, :verify_measurements] diff --git a/lib/twitter/base.rb b/lib/twitter/base.rb index eb680d85c..185eaf59d 100644 --- a/lib/twitter/base.rb +++ b/lib/twitter/base.rb @@ -99,7 +99,7 @@ def define_attribute_method(key1, klass = nil, key2 = nil) # @param key2 [Symbol] def define_predicate_method(key1, key2 = key1) define_method(:"#{key1}?") do || - !!@attrs[key2] + !@attrs[key2].nil? && @attrs[key2] != false end memoize(:"#{key1}?") end