class HaveAPI::Fs::Context
Every component has its own Context
instance and passes it along to its children. Context
is used to pass information from the root of the tree to all its branches and leaves. Using the context, every component knows all its parents and can relate to them. It also contains a reference to the global {Cache} instance.
Attributes
cache[RW]
file_path[RW]
mountpoint[RW]
object_path[RW]
opts[RW]
url[RW]
Public Class Methods
new()
click to toggle source
# File lib/haveapi/fs/context.rb, line 10 def initialize @object_path = [] @file_path = [] end
Public Instance Methods
[](name)
click to toggle source
# File lib/haveapi/fs/context.rb, line 30 def [](name) item = @object_path.reverse.detect { |v| v[0] == name } item && item[1] end
[]=(name, value)
click to toggle source
# File lib/haveapi/fs/context.rb, line 26 def []=(name, value) set(name, value) end
clone()
click to toggle source
Calls superclass method
# File lib/haveapi/fs/context.rb, line 15 def clone c = super c.object_path = c.object_path.clone c.file_path = c.file_path.clone c end
last()
click to toggle source
# File lib/haveapi/fs/context.rb, line 35 def last @object_path.last[1] end
method_missing(name, *args)
click to toggle source
Calls superclass method
# File lib/haveapi/fs/context.rb, line 39 def method_missing(name, *args) self[name] || super end
set(name, value)
click to toggle source
# File lib/haveapi/fs/context.rb, line 22 def set(name, value) @object_path << [name, value] end