Class: Caco::Postgres::ConfSet
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- Caco::Postgres::ConfSet
- Defined in:
- lib/caco/postgres/conf_set.rb
Constant Summary collapse
- ProcessSingleValue =
Class.new(Trailblazer::Activity::Signal)
- ProcessMultipleValue =
Class.new(Trailblazer::Activity::Signal)
Instance Method Summary collapse
- #define_what_process(ctx, name: nil, names: nil, value: nil, values: nil) ⇒ Object
- #process_multiple_values(ctx, values:, aug:) ⇒ Object
- #process_single_value(ctx, name:, value:, aug:) ⇒ Object
Instance Method Details
#define_what_process(ctx, name: nil, names: nil, value: nil, values: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/caco/postgres/conf_set.rb', line 15 def define_what_process(ctx, name: nil, names: nil, value: nil, values: nil, **) if name && value return ProcessSingleValue elsif values and values.is_a?(Hash) return ProcessMultipleValue else return false end end |
#process_multiple_values(ctx, values:, aug:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/caco/postgres/conf_set.rb', line 38 def process_multiple_values(ctx, values:, aug:, **) ctx[:values] = {} values.each_pair do |name, value| ctx[:existing_value] = aug.get("/files/postgresql.conf/#{name}") ctx[:created] = true unless ctx[:existing_value] if ctx[:existing_value] == value next else ctx[:changed] = true ctx[:values][name.to_s] = aug.set("/files/postgresql.conf/#{name}", value) end end aug.save! if ctx[:changed] true end |
#process_single_value(ctx, name:, value:, aug:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/caco/postgres/conf_set.rb', line 25 def process_single_value(ctx, name:, value:, aug:, **) ctx[:existing_value] = aug.get("/files/postgresql.conf/#{name}") ctx[:created] = !ctx[:existing_value] if ctx[:existing_value] == value return true else ctx[:changed] = true ctx[:value] = aug.set("/files/postgresql.conf/#{name}", value) aug.save! end true end |