GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Make Merb::Config[]= work without calling setup 1st
fabien (author)
Wed Oct 01 14:43:57 -0700 2008
commit  0ac860413522aa030cb347bfe4ba5021035adf6d
tree    c75eda59577735cd97573a70d52c016021889acb
parent  f3ac3ecfc8fc718e95920b0053eeed546ebcf79d
...
56
57
58
59
 
60
61
62
63
64
65
66
 
 
67
68
69
...
56
57
58
 
59
60
61
62
63
64
 
 
65
66
67
68
69
0
@@ -56,14 +56,14 @@ module Merb
0
       # ==== Returns
0
       # Object:: The value of the configuration parameter.
0
       def [](key)
0
- (@configuration||={})[key]
0
+ (@configuration ||= setup)[key]
0
       end
0
 
0
       # ==== Parameters
0
       # key<Object>:: The key to set the parameter for.
0
       # val<Object>:: The value of the parameter.
0
- def []=(key,val)
0
- @configuration[key] = val
0
+ def []=(key, val)
0
+ (@configuration ||= setup)[key] = val
0
       end
0
 
0
       # ==== Parameters
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
 
4
5
6
7
 
8
9
10
...
199
200
201
202
 
203
...
1
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
18
19
20
21
...
210
211
212
 
213
214
0
@@ -1,10 +1,21 @@
0
 require File.dirname(__FILE__) + '/spec_helper'
0
 
0
-describe Merb::Config do
0
+describe "Merb::Config without .setup" do
0
+ it "should be able to try to get a non-existing key" do
0
+ Merb::Config[:does_not_exist].should == nil
0
+ end
0
+
0
+ it "should be able to set a configuration key" do
0
+ Merb::Config[:arbitrary_key] = "arbitrary_value"
0
+ Merb::Config[:arbitrary_key].should == "arbitrary_value"
0
+ end
0
+end
0
+
0
+describe "Merb::Config with .setup" do
0
   before do
0
     Merb::Config.setup
0
   end
0
-
0
+
0
   it "should be able to yield the configuration via #use" do
0
     res = nil
0
     Merb::Config.use {|c| res = c}
0
@@ -199,4 +210,4 @@ describe Merb::Config do
0
   it "has verbose mode turned off by default" do
0
     Merb::Config[:verbose].should be(false)
0
   end
0
-end
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.