Class: Readthis::Scripts
- Inherits:
-
Object
- Object
- Readthis::Scripts
- Defined in:
- lib/readthis/scripts.rb
Overview
The ‘Scripts` class is used to conveniently execute lua scripts. The first time a command is run it is stored on the server and subsequently referred to by its SHA. Each instance tracks SHAs separately, they are not global.
Instance Attribute Summary collapse
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
Instance Method Summary collapse
-
#initialize ⇒ Scripts
constructor
Creates a new Readthis::Scripts instance.
-
#run(command, store, keys, args = []) ⇒ Any
Run a named lua script with the provided keys and arguments.
Constructor Details
#initialize ⇒ Scripts
Creates a new Readthis::Scripts instance.
11 12 13 |
# File 'lib/readthis/scripts.rb', line 11 def initialize @loaded = {} end |
Instance Attribute Details
#loaded ⇒ Object (readonly)
Returns the value of attribute loaded.
8 9 10 |
# File 'lib/readthis/scripts.rb', line 8 def loaded @loaded end |
Instance Method Details
#run(command, store, keys, args = []) ⇒ Any
Run a named lua script with the provided keys and arguments.
28 29 30 31 32 33 34 |
# File 'lib/readthis/scripts.rb', line 28 def run(command, store, keys, args = []) store.evalsha( sha(command, store), Array(keys), Array(args) ) end |