Class: CFA::AugeasCollection
- Inherits:
-
Object
- Object
- CFA::AugeasCollection
- Extended by:
- Forwardable
- Defined in:
- lib/cfa/augeas_parser.rb
Overview
Represents list of same config options in augeas. For example comments are often stored in collections.
Instance Method Summary collapse
- #add(value, placer = AppendPlacer.new) ⇒ Object
- #delete(value) ⇒ Object
-
#initialize(tree, name) ⇒ AugeasCollection
constructor
A new instance of AugeasCollection.
Constructor Details
#initialize(tree, name) ⇒ AugeasCollection
Returns a new instance of AugeasCollection.
41 42 43 44 45 |
# File 'lib/cfa/augeas_parser.rb', line 41 def initialize(tree, name) @tree = tree @name = name load_collection end |
Instance Method Details
#add(value, placer = AppendPlacer.new) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/cfa/augeas_parser.rb', line 49 def add(value, placer = AppendPlacer.new) element = placer.new_element(@tree) element[:key] = augeas_name element[:value] = value element[:operation] = :add # FIXME: load_collection missing here end |
#delete(value) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/cfa/augeas_parser.rb', line 57 def delete(value) to_delete, to_mark = to_remove(value) .partition { |e| e[:operation] == :add } @tree.all_data.delete_if { |e| to_delete.include?(e) } to_mark.each { |e| e[:operation] = :remove } load_collection end |