Class: Yaoc::Helper::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/yaoc/helper/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope_name = "default", storage_source = ThreadGlobalStorage) ⇒ Scope



7
8
9
10
# File 'lib/yaoc/helper/scope.rb', line 7

def initialize(scope_name="default", storage_source=ThreadGlobalStorage)
  self.scope_name  = scope_name
  self.storage_source = storage_source
end

Instance Attribute Details

#scope_nameObject

Returns the value of attribute scope_name.



5
6
7
# File 'lib/yaoc/helper/scope.rb', line 5

def scope_name
  @scope_name
end

#storage_sourceObject

Returns the value of attribute storage_source.



5
6
7
# File 'lib/yaoc/helper/scope.rb', line 5

def storage_source
  @storage_source
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/yaoc/helper/scope.rb', line 20

def [](key)
  self.storage[key]
end

#[]=(key, value) ⇒ Object



16
17
18
# File 'lib/yaoc/helper/scope.rb', line 16

def []=(key, value)
  self.storage[key]=value
end

#clear!Object



24
25
26
# File 'lib/yaoc/helper/scope.rb', line 24

def clear!
  self.storage.clear
end

#fetch(*args, &block) ⇒ Object



28
29
30
# File 'lib/yaoc/helper/scope.rb', line 28

def fetch(*args, &block)
  self.storage.fetch(*args, &block)
end

#storageObject



12
13
14
# File 'lib/yaoc/helper/scope.rb', line 12

def storage
  storage_source.for(scope_name)
end