Skip to content

Commit

Permalink
Use alias instead of alias_method in a class body
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 16, 2016
1 parent 3d63641 commit cfd3ce7
Show file tree
Hide file tree
Showing 28 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Expand Up @@ -37,5 +37,5 @@ Style/DoubleNegation:
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Style/TrailingComma:
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: 'comma'
4 changes: 2 additions & 2 deletions lib/twitter/base.rb
Expand Up @@ -11,8 +11,8 @@ class Base
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
alias to_h attrs
alias to_hash to_h

class << self
# Define methods that retrieve the value from attributes
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/configuration.rb
Expand Up @@ -10,8 +10,8 @@ class Configuration < Twitter::Base
# @return [Integer]
attr_reader :characters_reserved_per_media, :max_media_per_upload,
:photo_size_limit, :short_url_length, :short_url_length_https
alias_method :short_uri_length, :short_url_length
alias_method :short_uri_length_https, :short_url_length_https
alias short_uri_length short_url_length
alias short_uri_length_https short_url_length_https

# Returns an array of photo sizes
#
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/cursor.rb
Expand Up @@ -8,8 +8,8 @@ class Cursor
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
alias to_h attrs
alias to_hash to_h

# Initializes a new Cursor
#
Expand All @@ -34,7 +34,7 @@ def initialize(key, klass, request)
def next_cursor
@attrs[:next_cursor] || -1
end
alias_method :next, :next_cursor
alias next next_cursor

# @return [Boolean]
def last?
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/direct_message.rb
Expand Up @@ -8,7 +8,7 @@ class DirectMessage < Twitter::Identity
include Twitter::Entities
# @return [String]
attr_reader :text
alias_method :full_text, :text
alias full_text text
object_attr_reader :User, :recipient
object_attr_reader :User, :sender
end
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/entities.rb
Expand Up @@ -61,13 +61,13 @@ def uris
entities(Entity::URI, :urls)
end
memoize :uris
alias_method :urls, :uris
alias urls uris

# @return [Boolean]
def uris?
uris.any?
end
alias_method :urls?, :uris?
alias urls? uris?

# @note Must include entities in your request for this method to work
# @return [Array<Twitter::Entity::UserMention>]
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/geo.rb
Expand Up @@ -6,6 +6,6 @@ class Geo < Twitter::Base
include Equalizer.new(:coordinates)
# @return [Array<Float>]
attr_reader :coordinates
alias_method :coords, :coordinates
alias coords coordinates
end
end
6 changes: 3 additions & 3 deletions lib/twitter/geo/point.rb
Expand Up @@ -7,14 +7,14 @@ class Point < Twitter::Geo
def latitude
coordinates[0]
end
alias_method :lat, :latitude
alias lat latitude

# @return [Integer]
def longitude
coordinates[1]
end
alias_method :long, :longitude
alias_method :lng, :longitude
alias long longitude
alias lng longitude
end
end
end
4 changes: 2 additions & 2 deletions lib/twitter/geo_results.rb
Expand Up @@ -7,8 +7,8 @@ class GeoResults
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
alias to_h attrs
alias to_hash to_h

# Initializes a new GeoResults object
#
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/list.rb
Expand Up @@ -16,21 +16,21 @@ def members_uri
Addressable::URI.parse("#{uri}/members") if uri?
end
memoize :members_uri
alias_method :members_url, :members_uri
alias members_url members_uri

# @return [Addressable::URI] The URI to the list subscribers.
def subscribers_uri
Addressable::URI.parse("#{uri}/subscribers") if uri?
end
memoize :subscribers_uri
alias_method :subscribers_url, :subscribers_uri
alias subscribers_url subscribers_uri

# @return [Addressable::URI] The URI to the list.
def uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}") if slug? && user.screen_name?
end
memoize :uri
alias_method :url, :uri
alias url uri

def uri?
!!uri
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/place.rb
Expand Up @@ -9,11 +9,11 @@ class Place < Twitter::Identity
attr_reader :attributes
# @return [String]
attr_reader :country, :full_name, :name
alias_method :woe_id, :id
alias_method :woeid, :id
alias woe_id id
alias woeid id
object_attr_reader :GeoFactory, :bounding_box
object_attr_reader :Place, :contained_within
alias_method :contained?, :contained_within?
alias contained? contained_within?
uri_attr_reader :uri

# Initializes a new place
Expand Down
8 changes: 4 additions & 4 deletions lib/twitter/profile.rb
Expand Up @@ -28,7 +28,7 @@ def alias_method_sub(method, pattern, replacement)
def profile_banner_uri(size = :web)
parse_encoded_uri(insecure_uri([@attrs[:profile_banner_url], size].join('/'))) unless @attrs[:profile_banner_url].nil?
end
alias_method :profile_banner_url, :profile_banner_uri
alias profile_banner_url profile_banner_uri

# Return the secure URL to the user's profile banner image
#
Expand All @@ -37,7 +37,7 @@ def profile_banner_uri(size = :web)
def profile_banner_uri_https(size = :web)
parse_encoded_uri([@attrs[:profile_banner_url], size].join('/')) unless @attrs[:profile_banner_url].nil?
end
alias_method :profile_banner_url_https, :profile_banner_uri_https
alias profile_banner_url_https profile_banner_uri_https

# @return [Boolean]
def profile_banner_uri?
Expand All @@ -53,7 +53,7 @@ def profile_banner_uri?
def profile_image_uri(size = :normal)
parse_encoded_uri(insecure_uri(profile_image_uri_https(size))) unless @attrs[:profile_image_url_https].nil?
end
alias_method :profile_image_url, :profile_image_uri
alias profile_image_url profile_image_uri

# Return the secure URL to the user's profile image
#
Expand All @@ -68,7 +68,7 @@ def profile_image_uri_https(size = :normal)
# https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png
parse_encoded_uri(@attrs[:profile_image_url_https].sub(PROFILE_IMAGE_SUFFIX_REGEX, profile_image_suffix(size))) unless @attrs[:profile_image_url_https].nil?
end
alias_method :profile_image_url_https, :profile_image_uri_https
alias profile_image_url_https profile_image_uri_https

# @return [Boolean]
def profile_image_uri?
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rate_limit.rb
Expand Up @@ -29,6 +29,6 @@ def reset_at
def reset_in
[(reset_at - Time.now).ceil, 0].max if reset_at
end
alias_method :retry_after, :reset_in
alias retry_after reset_in
end
end
6 changes: 3 additions & 3 deletions lib/twitter/rest/direct_messages.rb
Expand Up @@ -130,9 +130,9 @@ def create_direct_message(user, text, options = {})
options[:text] = text
perform_post_with_object('/1.1/direct_messages/new.json', options, Twitter::DirectMessage)
end
alias_method :d, :create_direct_message
alias_method :m, :create_direct_message
alias_method :dm, :create_direct_message
alias d create_direct_message
alias m create_direct_message
alias dm create_direct_message
end
end
end
12 changes: 6 additions & 6 deletions lib/twitter/rest/favorites.rb
Expand Up @@ -50,7 +50,7 @@ def favorites(*args)
def unfavorite(*args)
parallel_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
end
alias_method :destroy_favorite, :unfavorite
alias destroy_favorite unfavorite

# Favorites the specified Tweets as the authenticating user
#
Expand All @@ -74,8 +74,8 @@ def favorite(*args)
end
end.compact
end
alias_method :fav, :favorite
alias_method :fave, :favorite
alias fav favorite
alias fave favorite

# Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
#
Expand All @@ -97,9 +97,9 @@ def favorite!(*args)
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
end
end
alias_method :create_favorite!, :favorite!
alias_method :fav!, :favorite!
alias_method :fave!, :favorite!
alias create_favorite! favorite!
alias fav! favorite!
alias fave! favorite!
end
end
end
14 changes: 7 additions & 7 deletions lib/twitter/rest/friends_and_followers.rb
Expand Up @@ -113,7 +113,7 @@ def follow(*args)
end
follow!(new_friends.value - existing_friends.value, arguments.options)
end
alias_method :create_friendship, :follow
alias create_friendship follow

# Allows the authenticating user to follow the specified users
#
Expand All @@ -134,7 +134,7 @@ def follow!(*args)
perform_post_with_object('/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
end.compact
end
alias_method :create_friendship!, :follow!
alias create_friendship! follow!

# Allows the authenticating user to unfollow the specified users
#
Expand All @@ -151,7 +151,7 @@ def follow!(*args)
def unfollow(*args)
parallel_users_from_response(:post, '/1.1/friendships/destroy.json', args)
end
alias_method :destroy_friendship, :unfollow
alias destroy_friendship unfollow

# Allows one to enable or disable retweets and device notifications from the specified user.
#
Expand Down Expand Up @@ -186,8 +186,8 @@ def friendship(source, target, options = {})
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
perform_get_with_object('/1.1/friendships/show.json', options, Twitter::Relationship)
end
alias_method :friendship_show, :friendship
alias_method :relationship, :friendship
alias friendship_show friendship
alias relationship friendship

# Test for the existence of friendship between two users
#
Expand Down Expand Up @@ -250,7 +250,7 @@ def followers(*args)
def friends(*args)
cursor_from_response_with_user(:users, Twitter::User, '/1.1/friends/list.json', args)
end
alias_method :following, :friends
alias 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/rest/reference/get/friendships/no_retweets/ids
Expand All @@ -262,7 +262,7 @@ def friends(*args)
def no_retweet_ids(options = {})
perform_get('/1.1/friendships/no_retweets/ids.json', options).collect(&:to_i)
end
alias_method :no_retweets_ids, :no_retweet_ids
alias no_retweets_ids no_retweet_ids
end
end
end
2 changes: 1 addition & 1 deletion lib/twitter/rest/lists.rb
Expand Up @@ -34,7 +34,7 @@ module Lists
def lists(*args)
objects_from_response_with_user(Twitter::List, :get, '/1.1/lists/list.json', args)
end
alias_method :lists_subscribed_to, :lists
alias lists_subscribed_to lists

# Show tweet timeline for members of the specified list
#
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/oauth.rb
Expand Up @@ -29,7 +29,7 @@ def token(options = {})
response = HTTP.with(headers).post(url, form: options)
response.parse['access_token']
end
alias_method :bearer_token, :token
alias bearer_token token

# Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
#
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/rest/places_and_geo.rb
Expand Up @@ -58,7 +58,7 @@ def reverse_geocode(options = {})
def geo_search(options = {})
perform_get_with_object('/1.1/geo/search.json', options, Twitter::GeoResults)
end
alias_method :places_nearby, :geo_search
alias places_nearby geo_search

# Locates places near the given coordinates which are similar in name
#
Expand All @@ -77,7 +77,7 @@ def geo_search(options = {})
def similar_places(options = {})
perform_get_with_object('/1.1/geo/similar_places.json', options, Twitter::GeoResults)
end
alias_method :places_similar, :similar_places
alias places_similar similar_places
end
end
end
2 changes: 1 addition & 1 deletion lib/twitter/rest/request.rb
Expand Up @@ -15,7 +15,7 @@ class Request
BASE_URL = 'https://api.twitter.com'
attr_accessor :client, :headers, :options, :path, :rate_limit,
:request_method, :uri
alias_method :verb, :request_method
alias verb request_method

# @param client [Twitter::Client]
# @param request_method [String, Symbol]
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/rest/timelines.rb
Expand Up @@ -25,7 +25,7 @@ module Timelines
def mentions_timeline(options = {})
perform_get_with_objects('/1.1/statuses/mentions_timeline.json', options, Twitter::Tweet)
end
alias_method :mentions, :mentions_timeline
alias mentions mentions_timeline

# Returns the 20 most recent Tweets posted by the specified user
#
Expand Down Expand Up @@ -70,7 +70,7 @@ def retweeted_by_user(user, options = {})
user_timeline(user, opts)
end
end
alias_method :retweeted_by, :retweeted_by_user
alias retweeted_by retweeted_by_user

# Returns the 20 most recent retweets posted by the authenticating user
#
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/rest/trends.rb
Expand Up @@ -23,8 +23,8 @@ def trends(id = 1, options = {})
response = perform_get('/1.1/trends/place.json', options).first
Twitter::TrendResults.new(response)
end
alias_method :local_trends, :trends
alias_method :trends_place, :trends
alias local_trends trends
alias trends_place trends

# Returns the locations that Twitter has trending topic information for
#
Expand All @@ -37,7 +37,7 @@ def trends(id = 1, options = {})
def trends_available(options = {})
perform_get_with_objects('/1.1/trends/available.json', options, Twitter::Place)
end
alias_method :trend_locations, :trends_available
alias trend_locations trends_available

# Returns the locations that Twitter has trending topic information for, closest to a specified location.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/tweets.rb
Expand Up @@ -100,7 +100,7 @@ def destroy_status(*args)
perform_post_with_object("/1.1/statuses/destroy/#{extract_id(tweet)}.json", arguments.options, Twitter::Tweet)
end
end
alias_method :destroy_tweet, :destroy_status
alias destroy_tweet destroy_status

# Updates the authenticating user's status
#
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/search_results.rb
Expand Up @@ -10,8 +10,8 @@ class SearchResults
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
alias to_h attrs
alias to_hash to_h

# Initializes a new SearchResults object
#
Expand Down

0 comments on commit cfd3ce7

Please sign in to comment.