Class: Sohm::Command
- Inherits:
-
Object
- Object
- Sohm::Command
- Defined in:
- lib/sohm/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
Class Method Summary collapse
Instance Method Summary collapse
- #call(nido, redis) ⇒ Object
- #clean ⇒ Object
-
#initialize(operation, *args) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(operation, *args) ⇒ Command
Returns a new instance of Command.
13 14 15 16 17 |
# File 'lib/sohm/command.rb', line 13 def initialize(operation, *args) @operation = operation @args = args @keys = [] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/sohm/command.rb', line 10 def args @args end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
11 12 13 |
# File 'lib/sohm/command.rb', line 11 def keys @keys end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
9 10 11 |
# File 'lib/sohm/command.rb', line 9 def operation @operation end |
Class Method Details
.[](operation, head, *tail) ⇒ Object
3 4 5 6 7 |
# File 'lib/sohm/command.rb', line 3 def self.[](operation, head, *tail) return head if tail.empty? new(operation, head, *tail) end |
Instance Method Details
#call(nido, redis) ⇒ Object
19 20 21 22 23 |
# File 'lib/sohm/command.rb', line 19 def call(nido, redis) newkey(nido, redis) do |key| redis.call(@operation, key, *params(nido, redis)) end end |
#clean ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/sohm/command.rb', line 25 def clean keys.each do |key, redis| redis.call("DEL", key) end subcommands.each { |cmd| cmd.clean } end |