Class: Ramaze::State
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #detect ⇒ Object
-
#initialize ⇒ State
constructor
A new instance of State.
- #key?(key) ⇒ Boolean
- #wrap(&block) ⇒ Object
Constructor Details
#initialize ⇒ State
Returns a new instance of State.
3 4 5 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 3 def initialize @core = detect end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 16 def [](key) @core.current[key] end |
#[]=(key, value) ⇒ Object
20 21 22 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 20 def []=(key, value) @core.current[key] = value end |
#detect ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 7 def detect require 'fiber' @extract = :resume Ramaze::Fiber rescue LoadError @extract = :value ::Thread end |
#key?(key) ⇒ Boolean
24 25 26 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 24 def key?(key) @core.current.key?(key) end |
#wrap(&block) ⇒ Object
28 29 30 |
# File 'lib/ramaze/snippets/ramaze/state.rb', line 28 def wrap(&block) @core.new(&block).send(@extract) end |