lib/twitter/base.rb in twitter-7.0.0 vs lib/twitter/base.rb in twitter-8.0.0.rc.1
- old
+ new
@@ -1,10 +1,10 @@
-require 'addressable/uri'
-require 'forwardable'
-require 'memoizable'
-require 'twitter/null_object'
-require 'twitter/utils'
+require "addressable/uri"
+require "forwardable"
+require "memoizable"
+require "twitter/null_object"
+require "twitter/utils"
module Twitter
class Base
extend Forwardable
include Memoizable
@@ -44,14 +44,14 @@
# Define URI methods from attributes
#
# @param attrs [Array, Symbol]
def uri_attr_reader(*attrs)
attrs.each do |uri_key|
- array = uri_key.to_s.split('_')
- index = array.index('uri')
- array[index] = 'url'
- url_key = array.join('_').to_sym
+ array = uri_key.to_s.split("_")
+ index = array.index("uri")
+ array[index] = "url"
+ url_key = array.join("_").to_sym
define_uri_method(uri_key, url_key)
alias_method(url_key, uri_key)
define_predicate_method(uri_key, url_key)
alias_method(:"#{url_key}?", :"#{uri_key}?")
end
@@ -69,11 +69,11 @@
#
# @param key1 [Symbol]
# @param key2 [Symbol]
def define_uri_method(key1, key2)
define_method(key1) do
- Addressable::URI.parse(@attrs[key2].chomp('#')) unless @attrs[key2].nil?
+ Addressable::URI.parse(@attrs[key2].chomp("#")) unless @attrs[key2].nil?
end
memoize(key1)
end
# Dynamically define a method for an attribute
@@ -123,10 +123,10 @@
end
private
def attr_falsey_or_empty?(key)
- !@attrs[key] || @attrs[key].respond_to?(:empty?) && @attrs[key].empty?
+ !@attrs[key] || (@attrs[key].respond_to?(:empty?) && @attrs[key].empty?)
end
def attrs_for_object(key1, key2 = nil)
if key2.nil?
@attrs[key1]