-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up Twitter::User class into 4 classes
* Twitter::BasicUser * Twitter::SourceUser * Twitter::TargetUser * Twitter::User
- Loading branch information
Showing
10 changed files
with
120 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'twitter/identity' | ||
|
||
module Twitter | ||
class BasicUser < Twitter::Identity | ||
attr_reader :following, :screen_name | ||
|
||
alias following? following | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'twitter/basic_user' | ||
|
||
module Twitter | ||
class SourceUser < BasicUser | ||
attr_reader :all_replies, :blocking, :can_dm, :followed_by, :marked_spam, | ||
:notifications_enabled, :want_retweets | ||
alias all_replies? all_replies | ||
alias blocking? blocking | ||
alias can_dm? can_dm | ||
alias followed_by? followed_by | ||
alias marked_spam? marked_spam | ||
alias notifications_enabled? notifications_enabled | ||
alias want_retweets? want_retweets | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'twitter/basic_user' | ||
|
||
module Twitter | ||
class TargetUser < BasicUser | ||
attr_reader :followed_by | ||
alias followed_by? followed_by | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'helper' | ||
|
||
describe Twitter::BasicUser do | ||
|
||
describe "#==" do | ||
it "returns true when objects IDs are the same" do | ||
saved_search = Twitter::BasicUser.new(:id => 1, :name => "foo") | ||
other = Twitter::BasicUser.new(:id => 1, :name => "bar") | ||
(saved_search == other).should be_true | ||
end | ||
it "returns false when objects IDs are different" do | ||
saved_search = Twitter::BasicUser.new(:id => 1) | ||
other = Twitter::BasicUser.new(:id => 2) | ||
(saved_search == other).should be_false | ||
end | ||
it "returns false when classes are different" do | ||
saved_search = Twitter::BasicUser.new(:id => 1) | ||
other = Twitter::Identity.new(:id => 1) | ||
(saved_search == other).should be_false | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'helper' | ||
|
||
describe Twitter::SourceUser do | ||
|
||
describe "#==" do | ||
it "returns true when objects IDs are the same" do | ||
saved_search = Twitter::SourceUser.new(:id => 1, :name => "foo") | ||
other = Twitter::SourceUser.new(:id => 1, :name => "bar") | ||
(saved_search == other).should be_true | ||
end | ||
it "returns false when objects IDs are different" do | ||
saved_search = Twitter::SourceUser.new(:id => 1) | ||
other = Twitter::SourceUser.new(:id => 2) | ||
(saved_search == other).should be_false | ||
end | ||
it "returns false when classes are different" do | ||
saved_search = Twitter::SourceUser.new(:id => 1) | ||
other = Twitter::Identity.new(:id => 1) | ||
(saved_search == other).should be_false | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'helper' | ||
|
||
describe Twitter::TargetUser do | ||
|
||
describe "#==" do | ||
it "returns true when objects IDs are the same" do | ||
saved_search = Twitter::TargetUser.new(:id => 1, :name => "foo") | ||
other = Twitter::TargetUser.new(:id => 1, :name => "bar") | ||
(saved_search == other).should be_true | ||
end | ||
it "returns false when objects IDs are different" do | ||
saved_search = Twitter::TargetUser.new(:id => 1) | ||
other = Twitter::TargetUser.new(:id => 2) | ||
(saved_search == other).should be_false | ||
end | ||
it "returns false when classes are different" do | ||
saved_search = Twitter::TargetUser.new(:id => 1) | ||
other = Twitter::Identity.new(:id => 1) | ||
(saved_search == other).should be_false | ||
end | ||
end | ||
|
||
end |