Permalink
Browse files

Use alias_method instead of alias

  • Loading branch information...
1 parent ce6ac07 commit d5b44db75136330d17a11382e9cba7ec2f1605ce @sferik committed Dec 8, 2013
View
@@ -8,9 +8,9 @@ class Base
extend Forwardable
include Memoizable
attr_reader :attrs
- alias to_h attrs
- alias to_hash attrs
- alias to_hsh attrs
+ alias_method :to_h, :attrs
+ alias_method :to_hash, :attrs
+ alias_method :to_hsh, :attrs
class << self
@@ -3,8 +3,8 @@
module Twitter
class BasicUser < Twitter::Identity
attr_reader :following, :screen_name
- alias handle screen_name
- alias username screen_name
- alias user_name screen_name
+ alias_method :handle, :screen_name
+ alias_method :username, :screen_name
+ alias_method :user_name, :screen_name
end
end
@@ -5,10 +5,10 @@
module Twitter
class Client
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret
- alias oauth_token access_token
- alias oauth_token= access_token=
- alias oauth_token_secret access_token_secret
- alias oauth_token_secret= access_token_secret=
+ alias_method :oauth_token, :access_token
+ alias_method :oauth_token=, :access_token=
+ alias_method :oauth_token_secret, :access_token_secret
+ alias_method :oauth_token_secret=, :access_token_secret=
# Initializes a new Client object
#
@@ -4,8 +4,8 @@ module Twitter
class Configuration < Twitter::Base
attr_reader :characters_reserved_per_media, :max_media_per_upload,
:non_username_paths, :photo_size_limit, :short_url_length, :short_url_length_https
- alias short_uri_length short_url_length
- alias short_uri_length_https short_url_length_https
+ alias_method :short_uri_length, :short_url_length
+ alias_method :short_uri_length_https, :short_url_length_https
# Returns an array of photo sizes
#
View
@@ -4,9 +4,9 @@ module Twitter
class Cursor
include Enumerable
attr_reader :attrs
- alias to_h attrs
- alias to_hash attrs
- alias to_hsh attrs
+ alias_method :to_h, :attrs
+ alias_method :to_hash, :attrs
+ alias_method :to_hsh, :attrs
class << self
@@ -64,12 +64,12 @@ def each(start = 0, &block)
def next_cursor
@attrs[:next_cursor] || -1
end
- alias next next_cursor
+ alias_method :next, :next_cursor
def previous_cursor
@attrs[:previous_cursor]
end
- alias previous previous_cursor
+ alias_method :previous, :previous_cursor
# @return [Boolean]
def first?
@@ -5,7 +5,7 @@ module Twitter
class DirectMessage < Twitter::Identity
include Twitter::Creatable
attr_reader :text
- alias full_text text
+ alias_method :full_text, :text
object_attr_reader :User, :recipient
object_attr_reader :User, :sender
end
View
@@ -5,6 +5,6 @@ module Twitter
class Geo < Twitter::Base
include Equalizer.new(:coordinates)
attr_reader :coordinates
- alias coords coordinates
+ alias_method :coords, :coordinates
end
end
@@ -8,14 +8,14 @@ class Point < Twitter::Geo
def latitude
coordinates[0]
end
- alias lat latitude
+ alias_method :lat, :latitude
# @return [Integer]
def longitude
coordinates[1]
end
- alias long longitude
- alias lng longitude
+ alias_method :long, :longitude
+ alias_method :lng, :longitude
end
end
@@ -4,9 +4,9 @@ module Twitter
class GeoResults
include Twitter::Enumerable
attr_reader :attrs
- alias to_h attrs
- alias to_hash attrs
- alias to_hsh attrs
+ alias_method :to_h, :attrs
+ alias_method :to_hash, :attrs
+ alias_method :to_hsh, :attrs
class << self
View
@@ -13,21 +13,21 @@ def members_uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
end
memoize :members_uri
- alias members_url members_uri
+ alias_method :members_url, :members_uri
# @return [Addressable::URI] The URI to the list subscribers.
def subscribers_uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
end
memoize :subscribers_uri
- alias subscribers_url subscribers_uri
+ alias_method :subscribers_url, :subscribers_uri
# @return [Addressable::URI] The URI to the list.
def uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
end
memoize :uri
- alias url uri
+ alias_method :url, :uri
end
end
@@ -4,10 +4,10 @@
module Twitter
class Place < Twitter::Base
attr_reader :attributes, :country, :full_name, :name, :woeid
- alias woe_id woeid
+ alias_method :woe_id, :woeid
object_attr_reader :GeoFactory, :bounding_box
object_attr_reader :Place, :contained_within
- alias contained? contained_within?
+ alias_method :contained?, :contained_within?
uri_attr_reader :uri
# @param other [Twitter::Place]
@@ -26,7 +26,7 @@ def reset_at
def reset_in
[(reset_at - Time.now).ceil, 0].max if reset_at
end
- alias retry_after reset_in
+ alias_method :retry_after, :reset_in
end
end
@@ -127,9 +127,9 @@ def create_direct_message(user, text, options = {})
options[:text] = text
object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/new.json", options)
end
- alias d create_direct_message
- alias m create_direct_message
- alias dm create_direct_message
+ alias_method :d, :create_direct_message
+ alias_method :m, :create_direct_message
+ alias_method :dm, :create_direct_message
deprecate_alias :direct_message_create, :create_direct_message
end
@@ -50,7 +50,7 @@ def favorites(*args)
def unfavorite(*args)
threaded_objects_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", args)
end
- alias destroy_favorite unfavorite
+ alias_method :destroy_favorite, :unfavorite
deprecate_alias :favorite_destroy, :unfavorite
# Favorites the specified Tweets as the authenticating user
@@ -76,8 +76,8 @@ def favorite(*args)
end
end.compact
end
- alias fav favorite
- alias fave favorite
+ alias_method :fav, :favorite
+ alias_method :fave, :favorite
deprecate_alias :favorite_create, :favorite
# Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
@@ -104,9 +104,9 @@ def favorite!(*args)
end
end
end
- alias create_favorite! favorite!
- alias fav! favorite!
- alias fave! favorite!
+ alias_method :create_favorite!, :favorite!
+ alias_method :fav!, :favorite!
+ alias_method :fave!, :favorite!
deprecate_alias :favorite_create!, :favorite!
end
@@ -118,7 +118,7 @@ def follow(*args)
end
follow!(new_friends.value - existing_friends.value, arguments.options)
end
- alias create_friendship follow
+ alias_method :create_friendship, :follow
deprecate_alias :friendship_create, :follow
# Allows the authenticating user to follow the specified users
@@ -145,7 +145,7 @@ def follow!(*args)
end
end.compact
end
- alias create_friendship! follow!
+ alias_method :create_friendship!, :follow!
deprecate_alias :friendship_create!, :follow!
# Allows the authenticating user to unfollow the specified users
@@ -163,7 +163,7 @@ def follow!(*args)
def unfollow(*args)
threaded_user_objects_from_response(:post, "/1.1/friendships/destroy.json", args)
end
- alias destroy_friendship unfollow
+ alias_method :destroy_friendship, :unfollow
deprecate_alias :friendship_destroy, :unfollow
# Allows one to enable or disable retweets and device notifications from the specified user.
@@ -199,8 +199,8 @@ def friendship(source, target, options = {})
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
object_from_response(Twitter::Relationship, :get, "/1.1/friendships/show.json", options)
end
- alias friendship_show friendship
- alias relationship friendship
+ alias_method :friendship_show, :friendship
+ alias_method :relationship, :friendship
# Test for the existence of friendship between two users
#
@@ -267,7 +267,7 @@ def followers(*args)
def friends(*args)
cursor_from_response_with_user(:users, Twitter::User, :get, "/1.1/friends/list.json", args)
end
- alias following friends
+ alias_method :following, :friends
# Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids
@@ -279,7 +279,7 @@ def friends(*args)
def no_retweet_ids(options = {})
get("/1.1/friendships/no_retweets/ids.json", options)[:body].map(&:to_i)
end
- alias no_retweets_ids no_retweet_ids
+ alias_method :no_retweets_ids, :no_retweet_ids
end
end
@@ -33,7 +33,7 @@ module Lists
def lists(*args)
objects_from_response_with_user(Twitter::List, :get, "/1.1/lists/list.json", args)
end
- alias lists_subscribed_to lists
+ alias_method :lists_subscribed_to, :lists
# Show tweet timeline for members of the specified list
#
@@ -25,7 +25,7 @@ module OAuth
def token
object_from_response(Twitter::Token, :post, "/oauth2/token", :grant_type => "client_credentials", :bearer_token_request => true)
end
- alias bearer_token token
+ alias_method :bearer_token, :token
# Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
#
@@ -59,7 +59,7 @@ def reverse_geocode(options = {})
def geo_search(options = {})
object_from_response(Twitter::GeoResults, :get, "/1.1/geo/search.json", options)
end
- alias places_nearby geo_search
+ alias_method :places_nearby, :geo_search
# Locates places near the given coordinates which are similar in name
#
@@ -78,7 +78,7 @@ def geo_search(options = {})
def similar_places(options = {})
object_from_response(Twitter::GeoResults, :get, "/1.1/geo/similar_places.json", options)
end
- alias places_similar similar_places
+ alias_method :places_similar, :similar_places
end
end
@@ -26,7 +26,7 @@ module Timelines
def mentions_timeline(options = {})
objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/mentions_timeline.json", options)
end
- alias mentions mentions_timeline
+ alias_method :mentions, :mentions_timeline
# Returns the 20 most recent Tweets posted by the specified user
#
@@ -71,7 +71,7 @@ def retweeted_by_user(user, options = {})
user_timeline(user, opts)
end
end
- alias retweeted_by retweeted_by_user
+ alias_method :retweeted_by, :retweeted_by_user
# Returns the 20 most recent retweets posted by the authenticating user
#
@@ -22,8 +22,8 @@ def trends(id = 1, options = {})
options[:id] = id
object_from_response(Twitter::TrendResults, :get, "/1.1/trends/place.json", options)
end
- alias local_trends trends
- alias trends_place trends
+ alias_method :local_trends, :trends
+ alias_method :trends_place, :trends
# Returns the locations that Twitter has trending topic information for
#
@@ -36,7 +36,7 @@ def trends(id = 1, options = {})
def trends_available(options = {})
objects_from_response(Twitter::Place, :get, "/1.1/trends/available.json", options)
end
- alias trend_locations trends_available
+ alias_method :trend_locations, :trends_available
# Returns the locations that Twitter has trending topic information for, closest to a specified location.
#
@@ -96,7 +96,7 @@ def statuses(*args)
def destroy_status(*args)
threaded_tweets_from_response(:post, "/1.1/statuses/destroy", args)
end
- alias destroy_tweet destroy_status
+ alias_method :destroy_tweet, :destroy_status
deprecate_alias :status_destroy, :destroy_status
deprecate_alias :tweet_destroy, :destroy_status
@@ -49,7 +49,7 @@ def settings(options = {})
def verify_credentials(options = {})
object_from_response(Twitter::User, :get, "/1.1/account/verify_credentials.json", options)
end
- alias current_user verify_credentials
+ alias_method :current_user, :verify_credentials
# Sets which device Twitter delivers updates to for the authenticating user
#
Oops, something went wrong.

0 comments on commit d5b44db

Please sign in to comment.