title: Ruby (Rails) Delegate attributes to another model's method?
body: <p>-EDIT-</p>
  
  <p>After reading about the Delegate method from the first answer, my question is this, is it possible to delegate two different methods to another single method.</p>
  
  <p>IE: I currently have: @photo.attachment.file.url, and @photo.attachment.height, and @photo.attachment.width</p>
  
  <p>I'd like to be able to access all of these via @photo.file.url, @photo.file.height, @photo.file.width.</p>
  
  <p>The reason for the syntax is Attachment is a model that uses Paperclip to manage files, Paperclip is generating the .file method (the model is called Attachment, the model uses Paperclip's <code>has_attached_file :file</code>).</p>
  
  <p>-ORIGINAL QUESTION-</p>
  
  <p>I was wondering about aliasing methods and attributes in Ruby (I think this is a general ruby question, although my application is in Rails 3):</p>
  
  <p>I have two models: Photo has_one Attachment.</p>
  
  <p>Attachment has "height" and "width" attributes, and a "file" method (from Paperclip).</p>
  
  <p>So by default I can access bits of the Attachment model like so:</p>
  
  <pre><code>photo.attachment.width # returns width in px
  photo.attachment.height # returns height in px
  photo.attachment.file # returns file path
  photo.attachment.file.url #returns url for the default style variant of the image
  photo.attachment.file.url(:style) #returns the url for a given style variant of the image
  </code></pre>
  
  <p>Now, in my photo class I have created this method:</p>
  
  <pre><code>def file(*args)
      attachment.file(*args)
  end
  </code></pre>
  
  <p>So, now I can simply use:</p>
  
  <pre><code>photo.file # returns file path
  photo.file.url # returns file url (or variant url if you pass a style symbol)
  </code></pre>
  
  <p>My question is, I was able to direct <code>photo.attachment.file</code> to just <code>photo.file</code>, but can I also map height and width to <code>photo.file</code>, so that, for the sake of consistency, I could access the height and width attributes through <code>photo.file.height</code> and <code>photo.file.width</code>?</p>
  
  <p>Is such a thing possible, and if so what does it look like?</p>