Class: ChefAB::BaseUpgrader
- Inherits:
-
Object
- Object
- ChefAB::BaseUpgrader
- Defined in:
- lib/chef-ab/base_upgrader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#node_id ⇒ Object
Returns the value of attribute node_id.
Instance Method Summary collapse
- #execute(&block) ⇒ Object
-
#initialize(options) ⇒ BaseUpgrader
constructor
A new instance of BaseUpgrader.
- #should_execute?(threshold) ⇒ Boolean
Constructor Details
#initialize(options) ⇒ BaseUpgrader
Returns a new instance of BaseUpgrader.
7 8 9 10 11 12 13 14 15 |
# File 'lib/chef-ab/base_upgrader.rb', line 7 def initialize() @node_id = [:node_id] raise "node_id is a mandatory options" unless @node_id if @node_id.is_a? Integer @hash = node_id else @hash = Zlib.crc32 (@node_id.to_s) end end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
5 6 7 |
# File 'lib/chef-ab/base_upgrader.rb', line 5 def hash @hash end |
#node_id ⇒ Object
Returns the value of attribute node_id.
5 6 7 |
# File 'lib/chef-ab/base_upgrader.rb', line 5 def node_id @node_id end |
Instance Method Details
#execute(&block) ⇒ Object
21 22 23 24 25 |
# File 'lib/chef-ab/base_upgrader.rb', line 21 def execute(&block) if block_given? && should_execute? block.call end end |
#should_execute?(threshold) ⇒ Boolean
17 18 19 |
# File 'lib/chef-ab/base_upgrader.rb', line 17 def should_execute?(threshold) @hash < threshold end |