Class: Patch::Patch
- Inherits:
-
Object
- Object
- Patch::Patch
- Defined in:
- lib/patch/patch.rb
Overview
A single patch consisting of a node mapping and actions
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#maps ⇒ Object
readonly
Returns the value of attribute maps.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#default_messages ⇒ Array<Patch::Message>
Patch messages for the default values in the patch.
-
#enable ⇒ Boolean
Enable the given nodes to implement this patch.
-
#initialize(name, maps, actions) ⇒ Patch
constructor
A new instance of Patch.
Constructor Details
#initialize(name, maps, actions) ⇒ Patch
Returns a new instance of Patch.
11 12 13 14 |
# File 'lib/patch/patch.rb', line 11 def initialize(name, maps, actions) @name = name populate(maps, actions) end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
6 7 8 |
# File 'lib/patch/patch.rb', line 6 def actions @actions end |
#maps ⇒ Object (readonly)
Returns the value of attribute maps.
6 7 8 |
# File 'lib/patch/patch.rb', line 6 def maps @maps end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/patch/patch.rb', line 6 def name @name end |
Instance Method Details
#default_messages ⇒ Array<Patch::Message>
Patch messages for the default values in the patch
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/patch/patch.rb', line 18 def actions_with_default = @actions.select do |action| !action[:default].nil? && !action[:default][:value].nil? end actions_with_default.map do |action| value = action[:default][:value] index = @actions.index(action) Message.new(:index => index, :patch_name => @name, :value => value) end end |
#enable ⇒ Boolean
Enable the given nodes to implement this patch
32 33 34 35 |
# File 'lib/patch/patch.rb', line 32 def enable result = @maps.map { |map| map.enable(self) } result.any? end |