Class: Cachex::Node
- Inherits:
-
Object
- Object
- Cachex::Node
- Defined in:
- lib/cachex/node.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #add_child(node) ⇒ Object
- #add_tags(additional_tags) ⇒ Object
- #all_tags ⇒ Object
-
#initialize(key, tags = []) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(key, tags = []) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 |
# File 'lib/cachex/node.rb', line 6 def initialize(key, =[]) @children = [] @key = key @tags = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/cachex/node.rb', line 4 def key @key end |
Instance Method Details
#add_child(node) ⇒ Object
12 13 14 15 |
# File 'lib/cachex/node.rb', line 12 def add_child(node) @children ||= [] @children << node end |
#add_tags(additional_tags) ⇒ Object
17 18 19 |
# File 'lib/cachex/node.rb', line 17 def () @tags += end |
#all_tags ⇒ Object
21 22 23 |
# File 'lib/cachex/node.rb', line 21 def [@tags, @children.map(&:key), @children.map(&:all_tags)].flatten.compact.uniq end |