Class: MemoryStoragePlugin
Constant Summary
collapse
- @@data =
{}
Instance Attribute Summary
Attributes included from Rubko::Base
#parent
Instance Method Summary
collapse
#inspect, #to_s, #values
#config
#camelize, #finalize, #httpGet, #init, #initialize, #jsonParse, #loadController, #loadFile, #loadModel, #loadPlugin, #loadView, #method_missing, #uncamelize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Rubko::Base
Instance Method Details
#[](*path) ⇒ Object
25
26
27
|
# File 'lib/rubko/plugins/storage/memory.rb', line 25
def [](*path)
find(path)[nil]
end
|
#[]=(*path, val) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rubko/plugins/storage/memory.rb', line 29
def []=(*path, val)
path.map! { |x| escape x }
path.reduce( @@data ) { |v, k|
v[k] ||= {}
if k.equal? path.last v[k][nil] = val
end
v[k]
}
val
end
|
#keys(*path) ⇒ Object
41
42
43
44
45
|
# File 'lib/rubko/plugins/storage/memory.rb', line 41
def keys(*path)
find(path).keys.compact.map { |x|
unescape x
}
end
|
#prune(*path) ⇒ Object
47
48
49
50
|
# File 'lib/rubko/plugins/storage/memory.rb', line 47
def prune(*path)
last = escape path.pop
find(path).delete last
end
|
#rename(*path, name) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/rubko/plugins/storage/memory.rb', line 52
def rename(*path, name)
name = escape name
last = escape path.pop
hash = find path
return false if hash[name]
hash[name] = hash.delete last
true
end
|