Class: Familia::Validation::CommandRecorder::CommandSequence

Inherits:
Object
  • Object
show all
Defined in:
lib/familia/validation/command_recorder.rb

Overview

Represents a sequence of Redis commands with transaction boundaries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandSequence

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

#commandsObject (readonly)

Returns the value of attribute commands.



105
106
107
# File 'lib/familia/validation/command_recorder.rb', line 105

def commands
  @commands
end

#pipeline_blocksObject (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_blocksObject (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

#clearObject



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_countObject



145
146
147
# File 'lib/familia/validation/command_recorder.rb', line 145

def command_count
  @commands.length
end

#current_pipelineObject



141
142
143
# File 'lib/familia/validation/command_recorder.rb', line 141

def current_pipeline
  @pipeline_blocks.last
end

#current_transactionObject



137
138
139
# File 'lib/familia/validation/command_recorder.rb', line 137

def current_transaction
  @transaction_blocks.last
end

#end_pipelineObject



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_transactionObject



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_countObject



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_aObject



157
158
159
# File 'lib/familia/validation/command_recorder.rb', line 157

def to_a
  @commands
end

#transaction_countObject



149
150
151
# File 'lib/familia/validation/command_recorder.rb', line 149

def transaction_count
  @transaction_blocks.length
end