Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #337 from MagLev/johnnyt/hash-access

Add Maglev#[] and Maglev#[]= as accessors for #root
  • Loading branch information...
commit 7bc05ecf9dab023604596ff0c228c4bae70253a7 2 parents fb497e6 + c975bb1
@johnnyt johnnyt authored
Showing with 36 additions and 1 deletion.
  1. +27 −0 spec/maglev/maglev_spec.rb
  2. +9 −1 src/kernel/bootstrap/Maglev.rb
View
27 spec/maglev/maglev_spec.rb
@@ -0,0 +1,27 @@
+require File.expand_path '../../spec_helper', __FILE__
+
+describe 'Maglev' do
+
+ describe '#root' do
+ it 'references Maglev::PERSISTENT_ROOT' do
+ Maglev.root.should == Maglev::PERSISTENT_ROOT
+ end
+ end
+
+ describe '#[]' do
+ it 'references Maglev::PERSISTENT_ROOT' do
+ message = 'hello world'
+ Maglev::PERSISTENT_ROOT[:message] = message
+ Maglev[:message].should == message
+ end
+ end
+
+ describe '#[]=' do
+ it 'updates Maglev::PERSISTENT_ROOT' do
+ message = 'hello world'
+ Maglev[:message] = message
+ Maglev::PERSISTENT_ROOT[:message].should == message
+ end
+ end
+
+end
View
10 src/kernel/bootstrap/Maglev.rb
@@ -50,7 +50,15 @@ module Maglev
def root
PERSISTENT_ROOT
end
- module_function :root
+
+ def [](key)
+ root[key]
+ end
+
+ def []=(key, value)
+ root[key] = value
+ end
+ module_function :root, :[], :[]=
# Executes the block with the current thread in transient mode, which
# affects the following operations:
Please sign in to comment.
Something went wrong with that request. Please try again.