<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Class: Caricature::MethodCallRecorder</title> <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" /> <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script> <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script> <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script> <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script> </head> <body class="class"> <div id="metadata"> <div id="file-metadata"> <div id="file-list-section" class="section"> <h3 class="section-header">In Files</h3> <div class="section-body"> <ul> <li><a href="../lib/caricature/method_call_recorder_rb.html?TB_iframe=true&height=550&width=785" class="thickbox" title="lib/caricature/method_call_recorder.rb">lib/caricature/method_call_recorder.rb</a></li> </ul> </div> </div> </div> <div id="class-metadata"> <!-- Parent Class --> <div id="parent-class-section" class="section"> <h3 class="section-header">Parent</h3> <p class="link"><a href="../Object.html">Object</a></p> </div> <!-- Namespace Contents --> <!-- Method Quickref --> <div id="method-list-section" class="section"> <h3 class="section-header">Methods</h3> <ul class="link-list"> <li><a href="#M000081">::new</a></li> <li><a href="#M000082">#record_call</a></li> <li><a href="#M000087">#size</a></li> <li><a href="#M000084">#was_called?</a></li> </ul> </div> <!-- Included Modules --> </div> <div id="project-metadata"> <div id="fileindex-section" class="section project-section"> <h3 class="section-header">Files</h3> <ul> <li class="file"><a href="../README_markdown.html">README.markdown</a></li> </ul> </div> <div id="classindex-section" class="section project-section"> <h3 class="section-header">Class Index <span class="search-toggle"><img src="../images/find.png" height="16" width="16" alt="[+]" title="show/hide quicksearch" /></span></h3> <form action="#" method="get" accept-charset="utf-8" class="initially-hidden"> <fieldset> <legend>Quicksearch</legend> <input type="text" name="quicksearch" value="" class="quicksearch-field" /> </fieldset> </form> <ul class="link-list"> <li><a href="../Caricature.html">Caricature</a></li> <li><a href="../Caricature/ArgumentRecording.html">Caricature::ArgumentRecording</a></li> <li><a href="../Caricature/ClrClassDescriptor.html">Caricature::ClrClassDescriptor</a></li> <li><a href="../Caricature/ClrClassMessenger.html">Caricature::ClrClassMessenger</a></li> <li><a href="../Caricature/ClrInterfaceDescriptor.html">Caricature::ClrInterfaceDescriptor</a></li> <li><a href="../Caricature/ClrInterfaceIsolator.html">Caricature::ClrInterfaceIsolator</a></li> <li><a href="../Caricature/ClrInterfaceMessenger.html">Caricature::ClrInterfaceMessenger</a></li> <li><a href="../Caricature/ClrIsolator.html">Caricature::ClrIsolator</a></li> <li><a href="../Caricature/Expectation.html">Caricature::Expectation</a></li> <li><a href="../Caricature/ExpectationBuilder.html">Caricature::ExpectationBuilder</a></li> <li><a href="../Caricature/ExpectationSyntax.html">Caricature::ExpectationSyntax</a></li> <li><a href="../Caricature/Expectations.html">Caricature::Expectations</a></li> <li><a href="../Caricature/Interception.html">Caricature::Interception</a></li> <li><a href="../Caricature/Interception/ClassMethods.html">Caricature::Interception::ClassMethods</a></li> <li><a href="../Caricature/Isolation.html">Caricature::Isolation</a></li> <li><a href="../Caricature/Isolator.html">Caricature::Isolator</a></li> <li><a href="../Caricature/MemberDescriptor.html">Caricature::MemberDescriptor</a></li> <li><a href="../Caricature/Messenger.html">Caricature::Messenger</a></li> <li><a href="../Caricature/MethodCallRecorder.html">Caricature::MethodCallRecorder</a></li> <li><a href="../Caricature/MethodCallRecording.html">Caricature::MethodCallRecording</a></li> <li><a href="../Caricature/RubyIsolator.html">Caricature::RubyIsolator</a></li> <li><a href="../Caricature/RubyMessenger.html">Caricature::RubyMessenger</a></li> <li><a href="../Caricature/RubyObjectDescriptor.html">Caricature::RubyObjectDescriptor</a></li> <li><a href="../Caricature/TypeDescriptor.html">Caricature::TypeDescriptor</a></li> <li><a href="../Caricature/Verification.html">Caricature::Verification</a></li> <li><a href="../System.html">System</a></li> <li><a href="../System/String.html">System::String</a></li> <li><a href="../System/Type.html">System::Type</a></li> <li><a href="../Array.html">Array</a></li> <li><a href="../Class.html">Class</a></li> <li><a href="../Hash.html">Hash</a></li> <li><a href="../Module.html">Module</a></li> <li><a href="../Object.html">Object</a></li> <li><a href="../String.html">String</a></li> </ul> <div id="no-class-search-results" style="display: none;">No matching classes.</div> </div> </div> </div> <div id="documentation"> <h1 class="class">Caricature::MethodCallRecorder</h1> <div id="description"> <p> The recorder that will collect method calls and provides an interface for finding those recordings </p> </div> <!-- Constants --> <!-- Attributes --> <div id="attribute-method-details" class="method-section section"> <h3 class="section-header">Attributes</h3> <div id="method-calls-attribute-method" class="method-detail"> <a name="method_calls"></a> <div class="method-heading attribute-method-heading"> <span class="method-name">method_calls</span><span class="attribute-access-type">[R]</span> </div> <div class="method-description"> <p> gets the collection of method calls. This is a hash with the method name as key </p> </div> </div> </div> <!-- Methods --> <div id="public-class-method-details" class="method-section section"> <h3 class="section-header">Public Class Methods</h3> <div id="new-method" class="method-detail "> <a name="M000081"></a> <div class="method-heading"> <span class="method-name">new</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p> Initializes a new instance of a method call recorder every time a method gets called in an isolated object this gets stored in the method call recorder </p> <div class="method-source-code" id="new-source"> <pre> <span class="ruby-comment cmt"># File lib/caricature/method_call_recorder.rb, line 95</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-ivar">@method_calls</span> = {<span class="ruby-identifier">:instance</span> =<span class="ruby-operator">></span> {}, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">></span> {} } <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> </div> <div id="public-instance-method-details" class="method-section section"> <h3 class="section-header">Public Instance Methods</h3> <div id="record-call-method" class="method-detail "> <a name="M000082"></a> <div class="method-heading"> <span class="method-name">record_call</span><span class="method-args">(method_name, mode=:instance, *args, &block)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p> records a method call or increments the count of how many times this method was called. </p> <div class="method-source-code" id="record-call-source"> <pre> <span class="ruby-comment cmt"># File lib/caricature/method_call_recorder.rb, line 100</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">record_call</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-identifier">:instance</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-identifier">mn_sym</span> = <span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-identifier">method_calls</span>[<span class="ruby-identifier">mode</span>][<span class="ruby-identifier">mn_sym</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">MethodCallRecording</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">method_name</span> <span class="ruby-identifier">mc</span> = <span class="ruby-identifier">method_calls</span>[<span class="ruby-identifier">mode</span>][<span class="ruby-identifier">mn_sym</span>] <span class="ruby-identifier">mc</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-identifier">mc</span>.<span class="ruby-identifier">add_argument_variation</span> <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> <div id="size-method" class="method-detail "> <a name="M000087"></a> <div class="method-heading"> <span class="method-name">size</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p> returns the number of different methods that has been recorderd </p> <div class="method-source-code" id="size-source"> <pre> <span class="ruby-comment cmt"># File lib/caricature/method_call_recorder.rb, line 124</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span> <span class="ruby-ivar">@method_calls</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> <div id="was-called--method" class="method-detail "> <a name="M000084"></a> <div class="method-heading"> <span class="method-name">was_called?</span><span class="method-args">(method_name, mode=:instance, *args)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p> returns whether the method was actually called with the specified constraints </p> <div class="method-source-code" id="was-called--source"> <pre> <span class="ruby-comment cmt"># File lib/caricature/method_call_recorder.rb, line 109</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">was_called?</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-identifier">:instance</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-identifier">mc</span> = <span class="ruby-identifier">method_calls</span>[<span class="ruby-identifier">mode</span>][<span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mc</span> <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">mc</span>.<span class="ruby-identifier">find_argument_variations</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">mc</span> <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> </div> </div> <div id="rdoc-debugging-section-dump" class="debugging-section"> <p>Disabled; run with --debug to generate this.</p> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 1.1.6</small>.</p> </div> </body> </html>