Class: DumpCleaner::Cleanup::StepContext
- Inherits:
-
Object
- Object
- DumpCleaner::Cleanup::StepContext
- Includes:
- Inspection
- Defined in:
- lib/dump_cleaner/cleanup/step_context.rb
Instance Attribute Summary collapse
-
#cleanup_data ⇒ Object
Returns the value of attribute cleanup_data.
-
#current_value ⇒ Object
Returns the value of attribute current_value.
-
#orig_value ⇒ Object
readonly
Returns the value of attribute orig_value.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#repetition ⇒ Object
Returns the value of attribute repetition.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type:, cleanup_data:, orig_value: nil, record: {}, repetition: 0) ⇒ StepContext
constructor
A new instance of StepContext.
- #pretty_print(pp) ⇒ Object
- #to_h(subset: false) ⇒ Object
Methods included from Inspection
#inspect_step_context, #subset, #truncate
Constructor Details
#initialize(type:, cleanup_data:, orig_value: nil, record: {}, repetition: 0) ⇒ StepContext
Returns a new instance of StepContext.
13 14 15 16 17 18 19 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 13 def initialize(type:, cleanup_data:, orig_value: nil, record: {}, repetition: 0) @type = type @cleanup_data = cleanup_data @orig_value = @current_value = orig_value @record = record @repetition = repetition end |
Instance Attribute Details
#cleanup_data ⇒ Object
Returns the value of attribute cleanup_data.
10 11 12 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 10 def cleanup_data @cleanup_data end |
#current_value ⇒ Object
Returns the value of attribute current_value.
10 11 12 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 10 def current_value @current_value end |
#orig_value ⇒ Object (readonly)
Returns the value of attribute orig_value.
11 12 13 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 11 def orig_value @orig_value end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
11 12 13 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 11 def record @record end |
#repetition ⇒ Object
Returns the value of attribute repetition.
10 11 12 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 10 def repetition @repetition end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 11 def type @type end |
Class Method Details
.new_from(step_context, **params) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 21 def self.new_from(step_context, **params) context_copy = step_context.dup new_context = new(orig_value: params[:orig_value] || context_copy.orig_value, type: params[:type] || context_copy.type, cleanup_data: params[:cleanup_data] || context_copy.cleanup_data, record: params[:record] || context_copy.record, repetition: params[:repetition] || context_copy.repetition) new_context.current_value = params[:current_value] || context_copy.current_value new_context end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 41 def ==(other) to_h == other.to_h end |
#pretty_print(pp) ⇒ Object
37 38 39 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 37 def pretty_print(pp) to_h(subset: true).pretty_print(pp) end |
#to_h(subset: false) ⇒ Object
32 33 34 35 |
# File 'lib/dump_cleaner/cleanup/step_context.rb', line 32 def to_h(subset: false) { orig_value:, current_value:, type:, record:, repetition:, cleanup_data: subset ? subset(cleanup_data) : cleanup_data } end |