From 1e9def65277125f23739be034abd4059a42d2b87 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sun, 5 Apr 2009 13:03:18 -0400 Subject: [PATCH] Fixed friendship_exists? which was throwing mash error. Now returns object if object is not mashable. --- History | 1 + examples/friendship_existance.rb | 13 +++++++++++++ lib/twitter/request.rb | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 examples/friendship_existance.rb diff --git a/History b/History index a29a19dc3..2147de700 100644 --- a/History +++ b/History @@ -1,6 +1,7 @@ 0.5.1 - April 5, 2009 * 1 minor change * Added data error hash returned from twitter to a few of the exceptions to help with debugging + * Fixed friendship_exists?. Was throwing mash stringify keys error because it was returning true or false instead of hash or array. 0.5.0 - April 3, 2009 * 1 major rewrite for OAuth diff --git a/examples/friendship_existance.rb b/examples/friendship_existance.rb new file mode 100644 index 000000000..c3d5a2c00 --- /dev/null +++ b/examples/friendship_existance.rb @@ -0,0 +1,13 @@ +require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter') +require File.join(File.dirname(__FILE__), 'helpers', 'config_store') +require 'pp' + +config = ConfigStore.new("#{ENV['HOME']}/.twitter") + +oauth = Twitter::OAuth.new(config['token'], config['secret']) +oauth.authorize_from_access(config['atoken'], config['asecret']) + +client = Twitter::Base.new(oauth) + +puts client.friendship_exists?('jnunemaker', 'orderedlist') +puts client.friendship_exists?('jnunemaker', 'biz') \ No newline at end of file diff --git a/lib/twitter/request.rb b/lib/twitter/request.rb index 9efc60637..e8717c333 100644 --- a/lib/twitter/request.rb +++ b/lib/twitter/request.rb @@ -74,8 +74,10 @@ def parse(response) def mash(obj) if obj.is_a?(Array) obj.map { |item| Mash.new(item) } - else + elsif obj.is_a?(Hash) Mash.new(obj) + else + obj end end