-
-
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.
Use equalizer instead of manually overwriting #==
- Loading branch information
Showing
13 changed files
with
26 additions
and
105 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 |
---|---|---|
@@ -1,15 +1,10 @@ | ||
require 'equalizer' | ||
require 'twitter/base' | ||
|
||
module Twitter | ||
class Geo < Twitter::Base | ||
include Equalizer.new(:coordinates) | ||
attr_reader :coordinates | ||
alias coords coordinates | ||
|
||
# @param other [Twitter::Geo] | ||
# @return [Boolean] | ||
def ==(other) | ||
super || attr_equal(:coordinates, other) || attrs_equal(other) | ||
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 |
---|---|---|
@@ -1,24 +1,11 @@ | ||
require 'equalizer' | ||
require 'twitter/base' | ||
|
||
module Twitter | ||
class Size < Twitter::Base | ||
include Equalizer.new(:h, :w) | ||
attr_reader :h, :resize, :w | ||
alias height h | ||
alias width w | ||
|
||
# @param other [Twitter::Size] | ||
# @return [Boolean] | ||
def ==(other) | ||
super || size_equal(other) || attrs_equal(other) | ||
end | ||
|
||
private | ||
|
||
# @param other [Twitter::Size] | ||
# @return [Boolean] | ||
def size_equal(other) | ||
self.class == other.class && !other.h.nil? && h == other.h && !other.w.nil? && w == other.w | ||
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 |
---|---|---|
@@ -1,15 +1,10 @@ | ||
require 'equalizer' | ||
require 'twitter/base' | ||
|
||
module Twitter | ||
class Trend < Twitter::Base | ||
include Equalizer.new(:name) | ||
attr_reader :events, :name, :promoted_content, :query | ||
uri_attr_reader :uri | ||
|
||
# @param other [Twitter::Trend] | ||
# @return [Boolean] | ||
def ==(other) | ||
super || attr_equal(:name, other) || attrs_equal(other) | ||
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
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
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
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