title: How can I make DRY repeated code used in model methods and in controllers in Rails 3?
body: <p>I have the following methods 
  for a single model, and may have more.  I may also have some of the repeated code in a helper.  How can I make it DRY?</p>
  
  <pre><code>25   def full_name
   26     client = LinkedIn::Client.new(ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'])
   27     client.authorize_from_access(self.atoken, self.asecret)
   28     client.profile(id =&gt; self.uid)
   29     client.profile.first_name + " " + client.profile.last_name
   30   end
   31 
   32   def image_url
   33     client = LinkedIn::Client.new(ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'])
   34     client.authorize_from_access(self.atoken, self.asecret)
   35     client.profile(id =&gt; self.uid)
   36     client.profile(:fields =&gt; "picture-url").picture_url
   37   end
  </code></pre>
  
  <p>The code where I instantiate the client and access the profile id for the most part is repeated everytime I need to make a method call on the API.  It's just the API that changes.</p>
  
  <p>What happens when I also need to call in the controller (of a different model?)</p>
  
  <pre><code>29     if @review.save
   30       flash[:notice] = "Successfully created review."
   31       # check if allowed to post to LinkedIn and post
   32       if @review.post_linkedin?
   33         client = LinkedIn::Client.new(ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'])
   34         client.authorize_from_access(current_user.atoken, current_user.asecret)
   35         debugger 
   36         client.update_network("has shared expertise on &lt;a")
   37       end
  </code></pre>
  
  <p>How could I make it more dry?</p>