Class: Familia::Validation::CommandRecorder::CommandSequence
- Inherits:
-
Object
- Object
- Familia::Validation::CommandRecorder::CommandSequence
- Defined in:
- lib/familia/validation/command_recorder.rb
Overview
Represents a sequence of Redis commands with transaction boundaries
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#pipeline_blocks ⇒ Object
readonly
Returns the value of attribute pipeline_blocks.
-
#transaction_blocks ⇒ Object
readonly
Returns the value of attribute transaction_blocks.
Instance Method Summary collapse
-
#add_command(recorded_command) ⇒ Object
-
#clear ⇒ Object
-
#command_count ⇒ Object
-
#current_pipeline ⇒ Object
-
#current_transaction ⇒ Object
-
#end_pipeline ⇒ Object
-
#end_transaction ⇒ Object
-
#initialize ⇒ CommandSequence
constructor
A new instance of CommandSequence.
-
#pipeline_count ⇒ Object
-
#start_pipeline(context = {}) ⇒ Object
-
#start_transaction(context = {}) ⇒ Object
-
#to_a ⇒ Object
-
#transaction_count ⇒ Object
Constructor Details
#initialize ⇒ CommandSequence
Returns a new instance of CommandSequence.
107 108 109 110 111 |
# File 'lib/familia/validation/command_recorder.rb', line 107 def initialize @commands = [] @transaction_blocks = [] @pipeline_blocks = [] end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
105 106 107 |
# File 'lib/familia/validation/command_recorder.rb', line 105 def commands @commands end |
#pipeline_blocks ⇒ Object (readonly)
Returns the value of attribute pipeline_blocks.
105 106 107 |
# File 'lib/familia/validation/command_recorder.rb', line 105 def pipeline_blocks @pipeline_blocks end |
#transaction_blocks ⇒ Object (readonly)
Returns the value of attribute transaction_blocks.
105 106 107 |
# File 'lib/familia/validation/command_recorder.rb', line 105 def transaction_blocks @transaction_blocks end |
Instance Method Details
#add_command(recorded_command) ⇒ Object
113 114 115 |
# File 'lib/familia/validation/command_recorder.rb', line 113 def add_command(recorded_command) @commands << recorded_command end |
#clear ⇒ Object
161 162 163 164 165 |
# File 'lib/familia/validation/command_recorder.rb', line 161 def clear @commands.clear @transaction_blocks.clear @pipeline_blocks.clear end |
#command_count ⇒ Object
145 146 147 |
# File 'lib/familia/validation/command_recorder.rb', line 145 def command_count @commands.length end |
#current_pipeline ⇒ Object
141 142 143 |
# File 'lib/familia/validation/command_recorder.rb', line 141 def current_pipeline @pipeline_blocks.last end |
#current_transaction ⇒ Object
137 138 139 |
# File 'lib/familia/validation/command_recorder.rb', line 137 def current_transaction @transaction_blocks.last end |
#end_pipeline ⇒ Object
131 132 133 134 135 |
# File 'lib/familia/validation/command_recorder.rb', line 131 def end_pipeline return unless current_pipeline current_pipeline.finalize(@commands) end |
#end_transaction ⇒ Object
121 122 123 124 125 |
# File 'lib/familia/validation/command_recorder.rb', line 121 def end_transaction return unless current_transaction current_transaction.finalize(@commands) end |
#pipeline_count ⇒ Object
153 154 155 |
# File 'lib/familia/validation/command_recorder.rb', line 153 def pipeline_count @pipeline_blocks.length end |
#start_pipeline(context = {}) ⇒ Object
127 128 129 |
# File 'lib/familia/validation/command_recorder.rb', line 127 def start_pipeline(context = {}) @pipeline_blocks << PipelineBlock.new(context) end |
#start_transaction(context = {}) ⇒ Object
117 118 119 |
# File 'lib/familia/validation/command_recorder.rb', line 117 def start_transaction(context = {}) @transaction_blocks << TransactionBlock.new(context) end |
#to_a ⇒ Object
157 158 159 |
# File 'lib/familia/validation/command_recorder.rb', line 157 def to_a @commands end |
#transaction_count ⇒ Object
149 150 151 |
# File 'lib/familia/validation/command_recorder.rb', line 149 def transaction_count @transaction_blocks.length end |