Class: MultiRedis::Operation
- Inherits:
-
Object
- Object
- MultiRedis::Operation
- Defined in:
- lib/multi_redis.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #add_step(multi_type = nil, &block) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize(*args, &block) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(*args, &block) ⇒ Operation
Returns a new instance of Operation.
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/multi_redis.rb', line 121 def initialize *args, &block = args.last.kind_of?(Hash) ? args.pop : {} @target = args.shift || [:target] || self @redis = [:redis] @steps = [] DSL.new(self).instance_eval &block end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
119 120 121 |
# File 'lib/multi_redis.rb', line 119 def steps @steps end |
Instance Method Details
#add_step(multi_type = nil, &block) ⇒ Object
140 141 142 |
# File 'lib/multi_redis.rb', line 140 def add_step multi_type = nil, &block @steps << Step.new(@target, multi_type, block) end |
#execute(*args) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/multi_redis.rb', line 132 def execute *args if MultiRedis.executing? MultiRedis.register_operation self, *args else Executor.new([ self ], args: [ args ], redis: @redis).execute.first end end |