Class: Caco::Haproxy::ConfSet
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- Caco::Haproxy::ConfSet
- Defined in:
- lib/caco/haproxy/conf_set.rb
Instance Method Summary collapse
- #change_value(ctx, output:, name:, value:) ⇒ Object
- #check_values_are_the_same(ctx, value:, existing_value:) ⇒ Object
- #create_value(ctx, output:, name:, value:) ⇒ Object
Instance Method Details
#change_value(ctx, output:, name:, value:) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/caco/haproxy/conf_set.rb', line 28 def change_value(ctx, output:, name:, value:, **) ctx[:created] = false ctx[:changed] = true ctx[:new_config_content] = output.gsub!(/^#{name}=\"(.*)\"/, "#{name}=\"#{value}\"") true end |
#check_values_are_the_same(ctx, value:, existing_value:) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/caco/haproxy/conf_set.rb', line 43 def check_values_are_the_same(ctx, value:, existing_value:, **) if value == existing_value ctx[:changed] = nil ctx[:created] = nil true else false end end |
#create_value(ctx, output:, name:, value:) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/caco/haproxy/conf_set.rb', line 35 def create_value(ctx, output:, name:, value:, **) ctx[:created] = true ctx[:changed] = true output << "#{name}=\"#{value}\"\n" ctx[:new_config_content] = output true end |