Skip to content

Commit

Permalink
Ensure predicate methods return false for Twitter::NullObject
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Mar 19, 2014
1 parent 2ec17d8 commit f1b42bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 30 deletions.
34 changes: 6 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <a
href="#configuration">configuration</a>.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1b42bf

Please sign in to comment.