configatron 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +26 -19
- data/doc/classes/Class.html +169 -0
- data/doc/classes/Configatron.html +303 -0
- data/doc/classes/Configatron/LockedNamespace.html +146 -0
- data/doc/classes/Configatron/ProtectedParameter.html +146 -0
- data/doc/classes/Configatron/Store.html +830 -0
- data/doc/classes/Kernel.html +144 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +320 -0
- data/doc/files/lib/configatron/configatron_rb.html +108 -0
- data/doc/files/lib/configatron/core_ext/class_rb.html +101 -0
- data/doc/files/lib/configatron/core_ext/kernel_rb.html +101 -0
- data/doc/files/lib/configatron/core_ext/object_rb.html +101 -0
- data/doc/files/lib/configatron/core_ext/string_rb.html +101 -0
- data/doc/files/lib/configatron/errors_rb.html +101 -0
- data/doc/files/lib/configatron/store_rb.html +101 -0
- data/doc/files/lib/configatron_rb.html +108 -0
- data/doc/fr_class_index.html +32 -0
- data/doc/fr_file_index.html +35 -0
- data/doc/fr_method_index.html +56 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- metadata +23 -2
data/README
CHANGED
@@ -5,9 +5,10 @@ Configatron makes configuring your applications and scripts incredibly easy. No
|
|
5
5
|
==Examples
|
6
6
|
|
7
7
|
===Simple
|
8
|
+
|
8
9
|
configatron.email = 'me@example.com'
|
9
10
|
configatron.database_url = "postgres://localhost/mack_framework_rocks"
|
10
|
-
|
11
|
+
|
11
12
|
Now, anywhere in your code you can do the following:
|
12
13
|
|
13
14
|
configatron.email # => "me@example.com"
|
@@ -15,19 +16,19 @@ Now, anywhere in your code you can do the following:
|
|
15
16
|
|
16
17
|
Viola! Simple as can be.
|
17
18
|
|
18
|
-
Now you're saying, what if I want to have a 'default' set of options, but then override them later, based on other information? Simple again. Let's use our above example. We've configured our
|
19
|
+
Now you're saying, what if I want to have a 'default' set of options, but then override them later, based on other information? Simple again. Let's use our above example. We've configured our <tt>database_url</tt> option to be <tt>postgres://localhost/mack_framework_rocks</tt>. The problem with that is that is our production database url, not our development url. Fair enough, all you have to do is redeclare it:
|
19
20
|
|
20
21
|
configatron.database_url = "postgres://localhost/mack_framework_rocks_development"
|
21
22
|
|
22
|
-
|
23
23
|
becomes:
|
24
24
|
|
25
25
|
configatron.email # => "me@example.com"
|
26
26
|
configatron.database_url # => "postgres://localhost/mack_framework_rocks_development"
|
27
|
-
|
27
|
+
|
28
28
|
Notice how our other configuration parameters haven't changed? Cool, eh?
|
29
29
|
|
30
30
|
===Hash/YAML
|
31
|
+
|
31
32
|
You can configure configatron from a hash as well:
|
32
33
|
|
33
34
|
configatron.configure_from_hash({:email => {:pop => {:address => 'pop.example.com', :port => 110}}, :smtp => {:address => 'smtp.example.com'}})
|
@@ -35,17 +36,15 @@ You can configure configatron from a hash as well:
|
|
35
36
|
configatron.email.pop.address # => 'pop.example.com'
|
36
37
|
configatron.email.pop.port # => 110
|
37
38
|
# and so on...
|
38
|
-
|
39
|
+
|
39
40
|
Notice how they're all namespaced for your as well. The same holds true for YAML files:
|
40
41
|
|
41
42
|
configuration.configure_from_yaml('/path/to/file.yml')
|
42
|
-
|
43
|
-
When the 'reload' method is called on configatron then the YAML file will be re-read in case changes have been made.
|
44
43
|
|
45
44
|
===Namespaces
|
46
45
|
|
47
46
|
The question that should be on your lips is what I need to have namespaced configuration parameters. It's easy! Configatron allows you to create namespaces.
|
48
|
-
|
47
|
+
|
49
48
|
configatron.website_url = "http://www.mackframework.com"
|
50
49
|
configatron.email.pop.address = "pop.example.com"
|
51
50
|
configatron.email.pop.port = 110
|
@@ -57,7 +56,7 @@ becomes:
|
|
57
56
|
configatron.email.pop.address # => "pop.example.com"
|
58
57
|
configatron.email.smtp.address # => "smtp.example.com"
|
59
58
|
configatron.website_url # => "http://www.mackframework.com"
|
60
|
-
|
59
|
+
|
61
60
|
Configatron allows you to nest namespaces to your hearts content! Just keep going, it's that easy.
|
62
61
|
|
63
62
|
Of course you can update a single parameter n levels deep as well:
|
@@ -66,21 +65,27 @@ Of course you can update a single parameter n levels deep as well:
|
|
66
65
|
|
67
66
|
configatron.email.pop.address # => "pop2.example.com"
|
68
67
|
configatron.email.smtp.address # => "smtp.example.com"
|
69
|
-
|
68
|
+
|
70
69
|
===Misc.
|
71
70
|
|
72
|
-
Even if parameters haven't been set, you can still call them,
|
71
|
+
Even if parameters haven't been set, you can still call them, but you'll get a <tt>Configatron::Store</tt> object back. The Configatron::Store class, however, will respond true to <tt>.nil?</tt> if there are no parameters configured on it.
|
73
72
|
|
74
73
|
configatron.i.dont.exist.nil? # => true
|
75
|
-
configatron.i.dont.exist # =>
|
76
|
-
|
77
|
-
|
74
|
+
configatron.i.dont.exist # => Configatron::Store
|
75
|
+
|
76
|
+
If you want to get back an actual <tt>nil</tt> then you can use the <tt>retrieve</tt> method:
|
77
|
+
|
78
|
+
configatron.i.do.exist = [:some, :array]
|
79
|
+
configatron.i.dont.retrieve(:exist, nil) # => nil
|
80
|
+
configatron.i.do.retrieve(:exist, :foo) # => [:some, :array]
|
81
|
+
|
82
|
+
You can set 'default' values for parameters. If there is already a setting, it won't be replaced. This is useful if you've already done your 'configuration' and you call a library, that needs to have parameters set. The library can set its defaults, without worrying that it might have overridden your custom settings.
|
78
83
|
|
79
84
|
configatron.set_default(:name, 'Mark Bates')
|
80
85
|
configatron.name # => 'Mark Bates'
|
81
86
|
configatron.set_default(:name, 'Me')
|
82
87
|
configatron.name # => 'Mark Bates'
|
83
|
-
|
88
|
+
|
84
89
|
Sometimes in testing, or other situations, you want to temporarily change some settings. You can do this with the <tt>temp</tt> method:
|
85
90
|
|
86
91
|
configatron.one = 1
|
@@ -98,7 +103,7 @@ Sometimes in testing, or other situations, you want to temporarily change some s
|
|
98
103
|
configatron.letters.a # => 'A'
|
99
104
|
configatron.letters.b # => 'B'
|
100
105
|
configatron.letters.c # => nil
|
101
|
-
|
106
|
+
|
102
107
|
You can also pass in an optional Hash to the <tt>temp</tt>:
|
103
108
|
|
104
109
|
configatron.one = 1
|
@@ -118,12 +123,14 @@ You can also pass in an optional Hash to the <tt>temp</tt>:
|
|
118
123
|
Enjoy!
|
119
124
|
|
120
125
|
==Contact
|
121
|
-
Please mail bugs, suggestions and patches to <bugs@mackframework.com>.
|
122
126
|
|
123
|
-
|
127
|
+
Please mail bugs, suggestions and patches to "bugs@mackframework.com":mailto:bugs@mackframework.com
|
128
|
+
|
129
|
+
On the web at: "http://www.mackframework.com":http://www.mackframework.com
|
124
130
|
|
125
131
|
==License and Copyright
|
126
|
-
|
132
|
+
|
133
|
+
Copyright (C) 2008 Mark Bates, "http://www.mackframework.com":http://www.mackframework.com
|
127
134
|
|
128
135
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
129
136
|
|
@@ -0,0 +1,169 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Class</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Class</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/configatron/core_ext/class_rb.html">
|
59
|
+
lib/configatron/core_ext/class.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000001">to_configatron</a>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<!-- if includes -->
|
97
|
+
|
98
|
+
<div id="section">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if method_list -->
|
108
|
+
<div id="methods">
|
109
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
110
|
+
|
111
|
+
<div id="method-M000001" class="method-detail">
|
112
|
+
<a name="M000001"></a>
|
113
|
+
|
114
|
+
<div class="method-heading">
|
115
|
+
<a href="#M000001" class="method-signature">
|
116
|
+
<span class="method-name">to_configatron</span><span class="method-args">(*args)</span>
|
117
|
+
</a>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div class="method-description">
|
121
|
+
<p>
|
122
|
+
Returns access to configuration parameters named after the class.
|
123
|
+
</p>
|
124
|
+
<p>
|
125
|
+
Examples:
|
126
|
+
</p>
|
127
|
+
<pre>
|
128
|
+
configatron.foo.bar = :bar
|
129
|
+
configatron.a.b.c.d = 'D'
|
130
|
+
|
131
|
+
class Foo
|
132
|
+
end
|
133
|
+
|
134
|
+
module A
|
135
|
+
module B
|
136
|
+
class C
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Foo.to_configatron.bar # => :bar
|
142
|
+
A::B::C.to_configatron.d # => 'D'
|
143
|
+
</pre>
|
144
|
+
<p><a class="source-toggle" href="#"
|
145
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
146
|
+
<div class="method-source-code" id="M000001-source">
|
147
|
+
<pre>
|
148
|
+
<span class="ruby-comment cmt"># File lib/configatron/core_ext/class.rb, line 21</span>
|
149
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_configatron</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
150
|
+
22: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_configatron</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
151
|
+
23: <span class="ruby-keyword kw">end</span>
|
152
|
+
</pre>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
</div>
|
156
|
+
|
157
|
+
|
158
|
+
</div>
|
159
|
+
|
160
|
+
|
161
|
+
</div>
|
162
|
+
|
163
|
+
|
164
|
+
<div id="validator-badges">
|
165
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
</body>
|
169
|
+
</html>
|
@@ -0,0 +1,303 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Configatron</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Configatron</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/configatron/configatron_rb.html">
|
59
|
+
lib/configatron/configatron.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/lib/configatron/errors_rb.html">
|
63
|
+
lib/configatron/errors.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/configatron/store_rb.html">
|
67
|
+
lib/configatron/store.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
<tr class="top-aligned-row">
|
74
|
+
<td><strong>Parent:</strong></td>
|
75
|
+
<td>
|
76
|
+
Object
|
77
|
+
</td>
|
78
|
+
</tr>
|
79
|
+
</table>
|
80
|
+
</div>
|
81
|
+
<!-- banner header -->
|
82
|
+
|
83
|
+
<div id="bodyContent">
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
<div id="contextContent">
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="method-list">
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
95
|
+
|
96
|
+
<div class="name-list">
|
97
|
+
<a href="#M000002">method_missing</a>
|
98
|
+
<a href="#M000003">reset!</a>
|
99
|
+
<a href="#M000004">temp</a>
|
100
|
+
<a href="#M000006">temp_end</a>
|
101
|
+
<a href="#M000005">temp_start</a>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if includes -->
|
109
|
+
<div id="includes">
|
110
|
+
<h3 class="section-bar">Included Modules</h3>
|
111
|
+
|
112
|
+
<div id="includes-list">
|
113
|
+
<span class="include-name">Singleton</span>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div id="section">
|
118
|
+
|
119
|
+
<div id="class-list">
|
120
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
121
|
+
|
122
|
+
Class <a href="Configatron/LockedNamespace.html" class="link">Configatron::LockedNamespace</a><br />
|
123
|
+
Class <a href="Configatron/ProtectedParameter.html" class="link">Configatron::ProtectedParameter</a><br />
|
124
|
+
Class <a href="Configatron/Store.html" class="link">Configatron::Store</a><br />
|
125
|
+
|
126
|
+
</div>
|
127
|
+
|
128
|
+
|
129
|
+
<div id="aliases-list">
|
130
|
+
<h3 class="section-bar">External Aliases</h3>
|
131
|
+
|
132
|
+
<div class="name-list">
|
133
|
+
<table summary="aliases">
|
134
|
+
<tr class="top-aligned-row context-row">
|
135
|
+
<td class="context-item-name">send</td>
|
136
|
+
<td>-></td>
|
137
|
+
<td class="context-item-value">send!</td>
|
138
|
+
</tr>
|
139
|
+
</table>
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<!-- if method_list -->
|
148
|
+
<div id="methods">
|
149
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
150
|
+
|
151
|
+
<div id="method-M000002" class="method-detail">
|
152
|
+
<a name="M000002"></a>
|
153
|
+
|
154
|
+
<div class="method-heading">
|
155
|
+
<a href="#M000002" class="method-signature">
|
156
|
+
<span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
|
157
|
+
</a>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
<p>
|
162
|
+
Forwards the method call onto the ‘namespaced’ <a
|
163
|
+
href="Configatron/Store.html">Configatron::Store</a>
|
164
|
+
</p>
|
165
|
+
<p><a class="source-toggle" href="#"
|
166
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
167
|
+
<div class="method-source-code" id="M000002-source">
|
168
|
+
<pre>
|
169
|
+
<span class="ruby-comment cmt"># File lib/configatron/configatron.rb, line 14</span>
|
170
|
+
14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
171
|
+
15: <span class="ruby-ivar">@_store</span>[<span class="ruby-ivar">@_namespace</span>.<span class="ruby-identifier">last</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
172
|
+
16: <span class="ruby-keyword kw">end</span>
|
173
|
+
</pre>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<div id="method-M000003" class="method-detail">
|
179
|
+
<a name="M000003"></a>
|
180
|
+
|
181
|
+
<div class="method-heading">
|
182
|
+
<a href="#M000003" class="method-signature">
|
183
|
+
<span class="method-name">reset!</span><span class="method-args">()</span>
|
184
|
+
</a>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<div class="method-description">
|
188
|
+
<p>
|
189
|
+
Removes ALL configuration parameters
|
190
|
+
</p>
|
191
|
+
<p><a class="source-toggle" href="#"
|
192
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
193
|
+
<div class="method-source-code" id="M000003-source">
|
194
|
+
<pre>
|
195
|
+
<span class="ruby-comment cmt"># File lib/configatron/configatron.rb, line 19</span>
|
196
|
+
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span>
|
197
|
+
20: <span class="ruby-ivar">@_store</span> = {<span class="ruby-identifier">:default</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>}
|
198
|
+
21: <span class="ruby-keyword kw">end</span>
|
199
|
+
</pre>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div id="method-M000004" class="method-detail">
|
205
|
+
<a name="M000004"></a>
|
206
|
+
|
207
|
+
<div class="method-heading">
|
208
|
+
<a href="#M000004" class="method-signature">
|
209
|
+
<span class="method-name">temp</span><span class="method-args">(options = nil) {|| ...}</span>
|
210
|
+
</a>
|
211
|
+
</div>
|
212
|
+
|
213
|
+
<div class="method-description">
|
214
|
+
<p>
|
215
|
+
Allows for the temporary overriding of parameters in a block. Takes an
|
216
|
+
optional Hash of parameters that will be applied before the block gets
|
217
|
+
called. At the end of the block, the temporary settings are deleted and the
|
218
|
+
original settings are reinstated.
|
219
|
+
</p>
|
220
|
+
<p><a class="source-toggle" href="#"
|
221
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
222
|
+
<div class="method-source-code" id="M000004-source">
|
223
|
+
<pre>
|
224
|
+
<span class="ruby-comment cmt"># File lib/configatron/configatron.rb, line 27</span>
|
225
|
+
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp</span>(<span class="ruby-identifier">options</span> = <span class="ruby-keyword kw">nil</span>)
|
226
|
+
28: <span class="ruby-keyword kw">begin</span>
|
227
|
+
29: <span class="ruby-identifier">temp_start</span>(<span class="ruby-identifier">options</span>)
|
228
|
+
30: <span class="ruby-keyword kw">yield</span>
|
229
|
+
31: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
230
|
+
32: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
231
|
+
33: <span class="ruby-keyword kw">ensure</span>
|
232
|
+
34: <span class="ruby-identifier">temp_end</span>
|
233
|
+
35: <span class="ruby-keyword kw">end</span>
|
234
|
+
36: <span class="ruby-keyword kw">end</span>
|
235
|
+
</pre>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div id="method-M000006" class="method-detail">
|
241
|
+
<a name="M000006"></a>
|
242
|
+
|
243
|
+
<div class="method-heading">
|
244
|
+
<a href="#M000006" class="method-signature">
|
245
|
+
<span class="method-name">temp_end</span><span class="method-args">()</span>
|
246
|
+
</a>
|
247
|
+
</div>
|
248
|
+
|
249
|
+
<div class="method-description">
|
250
|
+
<p><a class="source-toggle" href="#"
|
251
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
252
|
+
<div class="method-source-code" id="M000006-source">
|
253
|
+
<pre>
|
254
|
+
<span class="ruby-comment cmt"># File lib/configatron/configatron.rb, line 47</span>
|
255
|
+
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_end</span>
|
256
|
+
48: <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-ivar">@_namespace</span>.<span class="ruby-identifier">pop</span>)
|
257
|
+
49: <span class="ruby-keyword kw">end</span>
|
258
|
+
</pre>
|
259
|
+
</div>
|
260
|
+
</div>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div id="method-M000005" class="method-detail">
|
264
|
+
<a name="M000005"></a>
|
265
|
+
|
266
|
+
<div class="method-heading">
|
267
|
+
<a href="#M000005" class="method-signature">
|
268
|
+
<span class="method-name">temp_start</span><span class="method-args">(options = nil)</span>
|
269
|
+
</a>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p><a class="source-toggle" href="#"
|
274
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
275
|
+
<div class="method-source-code" id="M000005-source">
|
276
|
+
<pre>
|
277
|
+
<span class="ruby-comment cmt"># File lib/configatron/configatron.rb, line 38</span>
|
278
|
+
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_start</span>(<span class="ruby-identifier">options</span> = <span class="ruby-keyword kw">nil</span>)
|
279
|
+
39: <span class="ruby-identifier">n_space</span> = <span class="ruby-identifier">rand</span>
|
280
|
+
40: <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">n_space</span>] = <span class="ruby-ivar">@_store</span>[<span class="ruby-ivar">@_namespace</span>.<span class="ruby-identifier">last</span>].<span class="ruby-identifier">deep_clone</span>
|
281
|
+
41: <span class="ruby-ivar">@_namespace</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">n_space</span>
|
282
|
+
42: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>
|
283
|
+
43: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">:configure_from_hash</span>, <span class="ruby-identifier">options</span>)
|
284
|
+
44: <span class="ruby-keyword kw">end</span>
|
285
|
+
45: <span class="ruby-keyword kw">end</span>
|
286
|
+
</pre>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
|
292
|
+
</div>
|
293
|
+
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
|
298
|
+
<div id="validator-badges">
|
299
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
300
|
+
</div>
|
301
|
+
|
302
|
+
</body>
|
303
|
+
</html>
|