<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> Class: Ballast::Configuration — Documentation by YARD 0.8.7.6 </title> <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" /> <script type="text/javascript" charset="utf-8"> hasFrames = window.top.frames.main ? true : false; relpath = '../'; framesUrl = "../frames.html#!Ballast/Configuration.html"; </script> <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="../js/app.js"></script> </head> <body> <div id="header"> <div id="menu"> <a href="../_index.html">Index (C)</a> » <span class='title'><span class='object_link'><a href="../Ballast.html" title="Ballast (module)">Ballast</a></span></span> » <span class="title">Configuration</span> <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div> </div> <div id="search"> <a class="full_list_link" id="class_list_link" href="../class_list.html"> Class List </a> <a class="full_list_link" id="method_list_link" href="../method_list.html"> Method List </a> <a class="full_list_link" id="file_list_link" href="../file_list.html"> File List </a> </div> <div class="clear"></div> </div> <iframe id="search_frame"></iframe> <div id="content"><h1>Class: Ballast::Configuration </h1> <dl class="box"> <dt class="r1">Inherits:</dt> <dd class="r1"> <span class="inheritName">HashWithIndifferentAccess</span> <ul class="fullTree"> <li>Object</li> <li class="next">HashWithIndifferentAccess</li> <li class="next">Ballast::Configuration</li> </ul> <a href="#" class="inheritanceTree">show all</a> </dd> <dt class="r2 last">Defined in:</dt> <dd class="r2 last">lib/ballast/configuration.rb</dd> </dl> <div class="clear"></div> <h2>Overview</h2><div class="docstring"> <div class="discussion"> <p>A class which loads a list of YAML files in a folder and expose them in a dotted notation. For each file, only the subsection for the current environment is loaded, so each YAML document should be an hash.</p> </div> </div> <div class="tags"> </div> <h2> Class Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#default_environment-class_method" title="default_environment (class method)">+ (String) <strong>default_environment</strong> </a> </span> <span class="summary_desc"><div class='inline'><p>Returns the default environment.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="#default_root-class_method" title="default_root (class method)">+ (String) <strong>default_root</strong> </a> </span> <span class="summary_desc"><div class='inline'><p>Returns the default root directory to lookup a configuration.</p> </div></span> </li> </ul> <h2> Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#initialize-instance_method" title="#initialize (instance method)">- (Configuration) <strong>initialize</strong>(*sections, root: nil, environment: nil) </a> </span> <span class="note title constructor">constructor</span> <span class="summary_desc"><div class='inline'><p>Creates a new configuration.</p> </div></span> </li> </ul> <div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> <h3 class="signature first" id="initialize-instance_method"> - (<tt><span class='object_link'><a href="" title="Ballast::Configuration (class)">Configuration</a></span></tt>) <strong>initialize</strong>(*sections, root: nil, environment: nil) </h3><div class="docstring"> <div class="discussion"> <p>Creates a new configuration.</p> </div> </div> <div class="tags"> <p class="tag_title">Parameters:</p> <ul class="param"> <li> <span class='name'>sections</span> <span class='type'>(<tt>Array</tt>)</span> — <div class='inline'><p>A list of sections to load. Each section name should be the basename (without extension) of a file in the root folder. Subfolders are not supported.</p> </div> </li> <li> <span class='name'>root</span> <span class='type'>(<tt>String|NilClass</tt>)</span> — <div class='inline'><p>The root folder where look for file.</p> </div> </li> <li> <span class='name'>environment</span> <span class='type'>(<tt>String|NilClass</tt>)</span> — <div class='inline'><p>The environment to load.</p> </div> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 30 31 32 33 34 35 36 37 38 39 40 41</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/ballast/configuration.rb', line 30</span> <span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='rubyid_sections identifier id'>sections</span><span class='comma token'>,</span> <span class='label val'>root:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>environment:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span> <span class='rubyid_super super kw'>super</span><span class='lparen token'>(</span><span class='rparen token'>)</span> <span class='rubyid_root identifier id'>root</span> <span class='opasgn op'>||=</span> <span class='colon3 op'>::</span><span class='rubyid_Ballast constant id'>Ballast</span><span class='colon2 op'>::</span><span class='rubyid_Configuration constant id'>Configuration</span><span class='dot token'>.</span><span class='rubyid_default_root identifier id'>default_root</span> <span class='rubyid_environment identifier id'>environment</span> <span class='opasgn op'>||=</span> <span class='colon3 op'>::</span><span class='rubyid_Ballast constant id'>Ballast</span><span class='colon2 op'>::</span><span class='rubyid_Configuration constant id'>Configuration</span><span class='dot token'>.</span><span class='rubyid_default_environment identifier id'>default_environment</span> <span class='rubyid_sections identifier id'>sections</span><span class='dot token'>.</span><span class='rubyid_each identifier id'>each</span> <span class='rubyid_do do kw'>do</span> <span class='bitor op'>|</span><span class='rubyid_section identifier id'>section</span><span class='bitor op'>|</span> <span class='rubyid_content identifier id'>content</span> <span class='assign token'>=</span> <span class='rubyid_load_section identifier id'>load_section</span><span class='lparen token'>(</span><span class='rubyid_root identifier id'>root</span><span class='comma token'>,</span> <span class='rubyid_section identifier id'>section</span><span class='rparen token'>)</span> <span class='rubyid_self self kw'>self</span><span class='lbrack token'>[</span><span class='rubyid_section identifier id'>section</span><span class='dot token'>.</span><span class='rubyid_underscore identifier id'>underscore</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='rubyid_content identifier id'>content</span><span class='dot token'>.</span><span class='rubyid_fetch identifier id'>fetch</span><span class='lparen token'>(</span><span class='rubyid_environment identifier id'>environment</span><span class='comma token'>,</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='rparen token'>)</span> <span class='rubyid_end end kw'>end</span> <span class='rubyid_enable_dotted_access identifier id'>enable_dotted_access</span> <span class='rubyid_end end kw'>end</span> </pre> </td> </tr> </table> </div> </div> <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="default_environment-class_method"> + (<tt>String</tt>) <strong>default_environment</strong> </h3><div class="docstring"> <div class="discussion"> <p>Returns the default environment. It will be the first non-nil of the following: Rails environment, the Rack environment or “production”.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>String</tt>)</span> — <div class='inline'><p>The default environment.</p> </div> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 20 21 22</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/ballast/configuration.rb', line 20</span> <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_default_environment identifier id'>default_environment</span> <span class='rubyid_defined? defined kw'>defined?</span><span class='lparen token'>(</span><span class='rubyid_Rails constant id'>Rails</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='rubyid_Rails constant id'>Rails</span><span class='dot token'>.</span><span class='rubyid_env identifier id'>env</span> <span class='colon op'>:</span> <span class='rubyid_ENV constant id'>ENV</span><span class='dot token'>.</span><span class='rubyid_fetch identifier id'>fetch</span><span class='lparen token'>(</span><span class='string val'>"RACK_ENV"</span><span class='comma token'>,</span> <span class='string val'>"production"</span><span class='rparen token'>)</span> <span class='rubyid_end end kw'>end</span> </pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="default_root-class_method"> + (<tt>String</tt>) <strong>default_root</strong> </h3><div class="docstring"> <div class="discussion"> <p>Returns the default root directory to lookup a configuration. It will be the Rails root if set or the current folder.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>String</tt>)</span> — <div class='inline'><p>The default root directory to lookup a configuration.</p> </div> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 13 14 15</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/ballast/configuration.rb', line 13</span> <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_default_root identifier id'>default_root</span> <span class='rubyid_defined? defined kw'>defined?</span><span class='lparen token'>(</span><span class='rubyid_Rails constant id'>Rails</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='rubyid_Rails constant id'>Rails</span><span class='dot token'>.</span><span class='rubyid_root identifier id'>root</span><span class='dot token'>.</span><span class='rubyid_to_s identifier id'>to_s</span> <span class='colon op'>:</span> <span class='rubyid_Dir constant id'>Dir</span><span class='dot token'>.</span><span class='rubyid_pwd identifier id'>pwd</span> <span class='rubyid_end end kw'>end</span> </pre> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated on Wed Mar 9 10:37:57 2016 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.8.7.6 (ruby-2.3.0). </div> </body> </html>