Skip to content

Instantly share code, notes, and snippets.

@bhuga
Last active August 29, 2015 13:57
Show Gist options
  • Save bhuga/9556208 to your computer and use it in GitHub Desktop.
Save bhuga/9556208 to your computer and use it in GitHub Desktop.
Sane sawyer inspect for octokit
class Sawyer::Resource
def to_attrs
hash = self.attrs.clone
hash.keys.each do |k|
if hash[k].is_a?(Sawyer::Resource)
hash[k] = hash[k].to_attrs
end
end
hash
end
def inspect
to_attrs.respond_to?(:pretty_inspect) ? to_attrs.pretty_inspect : to_attrs.inspect
end
end
{:login=>"bhuga",
:id=>12676,
:gravatar_id=>"fcb052cb03de0357fc30978d9434bcb4",
:type=>"User",
:name=>"Ben Lavender",
:company=>"GitHub",
:blog=>"bhuga.net",
:location=>"New Orleans, LA",
:email=>nil,
:hireable=>false,
:bio=>"",
:public_repos=>70,
:public_gists=>28,
:followers=>109,
:following=>6,
:created_at=>2008-06-05 08:02:36 UTC,
:updated_at=>2014-03-14 19:19:34 UTC,
:private_gists=>45,
:total_private_repos=>7,
:owned_private_repos=>5,
:disk_usage=>36150,
:collaborators=>4,
:plan=>
{:name=>"small", :space=>1228800, :collaborators=>5, :private_repos=>10}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment