module SmashTheState::Operation::DryRun
Public Instance Methods
dry_run(params = {})
click to toggle source
dry runs are meant to produce the same types of output as a normal call/run, except they should not produce any side-effects (writing to a database, etc)
# File lib/smash_the_state/operation/dry_run.rb, line 54 def dry_run(params = {}) # if an valid dry run sequence has been specified, use it. otherwise run the main # sequence in "side-effect free mode" (filtering out steps that cause # side-effects) seq = if dry_run_sequence? dry_run_sequence else sequence.side_effect_free end seq.run_options[:dry] = true run_sequence(seq, params) end
Also aliased as: dry_call
dry_run_sequence(&block)
click to toggle source
# File lib/smash_the_state/operation/dry_run.rb, line 69 def dry_run_sequence(&block) # to keep the operation code cleaner, we will delegate dry run sequence building # to another module (allows us to have a method named :step without having to make # the operation :step method super complicated) @dry_run_builder ||= DryRun::Builder.new(sequence) # if a block is given, we want to evaluate it with the builder @dry_run_builder.instance_eval(&block) if block_given? # the builder will produce a side-effect-free sequence for us @dry_run_builder.dry_sequence end
dry_run_sequence?()
click to toggle source
a valid dry run sequence should have at least one step. if there isn't at least one step, the dry run sequence is basically a no-op
# File lib/smash_the_state/operation/dry_run.rb, line 84 def dry_run_sequence? !dry_run_sequence.steps.empty? end