Permalink
Browse files

reducing hash lookups

using instance variables to clean up some methods
  • Loading branch information...
1 parent 4283210 commit fcee15da04aed48da7271b3e343e16d5a598b11d @GeekOnCoffee GeekOnCoffee committed Jun 10, 2012
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/travis/github/payload/pull_request.rb
@@ -11,6 +11,8 @@ def initialize(payload)
GH.reset # FIXME: solve this somehow differently
@gh = GH.load(payload)
+ @repo = gh['repository']
+ @repo_owner = @repo['owner']
end
def action
@@ -27,20 +29,20 @@ def head_change?
def repository
@repository ||= {
- :name => gh['repository']['name'],
- :description => gh['repository']['description'],
- :url => gh['repository']['_links']['html']['href'],
- :owner_type => gh['repository']['owner']['type'],
- :owner_name => gh['repository']['owner']['login'],
- :owner_email => gh['repository']['owner']['email'],
- :private => !!gh['repository']['private']
+ :name => @repo['name'],
+ :description => @repo['description'],
+ :url => @repo['_links']['html']['href'],
+ :owner_type => @repo_owner['type'],
+ :owner_name => @repo_owner['login'],
+ :owner_email => @repo_owner['email'],
+ :private => !!@repo['private']
}
end
def owner
@owner ||= {
- :type => gh['repository']['owner']['type'],
- :login => gh['repository']['owner']['login']
+ :type => @repo_owner['type'],
+ :login => @repo_owner['login']
}
end

0 comments on commit fcee15d

Please sign in to comment.