Skip to content

Commit

Permalink
Custom equalizer for Twitter::Place
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Nov 28, 2013
1 parent 1c93835 commit 79c76a9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/twitter/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@

module Twitter
class Place < Twitter::Base
include Equalizer.new(:woeid)
attr_reader :attributes, :country, :full_name, :name, :woeid
alias woe_id woeid
object_attr_reader :GeoFactory, :bounding_box
object_attr_reader :Place, :contained_within
alias contained? contained_within?
uri_attr_reader :uri

# @param other [Twitter::Place]
# @return [Boolean]
def eql?(other)
super || instance_of?(other.class) && !woeid.nil? && other.respond_to?(:woeid) && woeid.eql?(other.woeid)
end

# @param other [Twitter::Place]
# @return [Boolean]
def ==(other)
other = coerce(other) if respond_to?(:coerce, true)
super || kind_of?(self.class) && !woeid.nil? && other.respond_to?(:woeid) && woeid == other.woeid
end

# @return [String]
def country_code
@attrs[:country_code] || @attrs[:countryCode]
Expand Down

0 comments on commit 79c76a9

Please sign in to comment.