<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>prefix= (ActiveResource::Base)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> <pre><span class="ruby-comment cmt"># File lib/active_resource/base.rb, line 234</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">prefix=</span>(<span class="ruby-identifier">value</span> = <span class="ruby-value str">'/'</span>) <span class="ruby-comment cmt"># Replace :placeholders with '#{embedded options[:lookups]}'</span> <span class="ruby-identifier">prefix_call</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/:\w+/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-node">"\#{options[#{key}]}"</span> } <span class="ruby-comment cmt"># Redefine the new methods.</span> <span class="ruby-identifier">code</span> = <span class="ruby-value str">"def prefix_source() \"\#{value}\" end\ndef prefix(options={}) \"\#{prefix_call}\" end\n"</span> <span class="ruby-identifier">silence_warnings</span> { <span class="ruby-identifier">instance_eval</span> <span class="ruby-identifier">code</span>, <span class="ruby-keyword kw">__FILE__</span>, <span class="ruby-keyword kw">__LINE__</span> } <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"Couldn't set prefix: #{$!}\n #{code}"</span> <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">end</span></pre> </body> </html>