class HaveAPI::Fs::Component::Children
An encapsulation of a Hash to store child components.
Attributes
context[RW]
Public Class Methods
new(ctx)
click to toggle source
@param [HaveAPI::Fs::Context] ctx
# File lib/haveapi/fs/component.rb, line 13 def initialize(ctx) @context = ctx @store = {} end
Public Instance Methods
[](k)
click to toggle source
# File lib/haveapi/fs/component.rb, line 18 def [](k) @store[k] end
[]=(k, v)
click to toggle source
Replace a child named `k` by a new child represented by `v`. The old child, if present, is invalidated and dropped from the cache. {Factory} is used to create an instance of `v`.
@param [Symbol] k @param [Array] v
# File lib/haveapi/fs/component.rb, line 28 def []=(k, v) if @store.has_key?(k) @store[k].invalidate @store[k].context.cache.drop_below(@store[k].path) end @store[k] = Factory.create(@context, k, *v) end
set(k, v)
click to toggle source
# File lib/haveapi/fs/component.rb, line 37 def set(k, v) @store[k] = v end