Class: Redtastic::ScriptManager
- Inherits:
-
Object
- Object
- Redtastic::ScriptManager
- Defined in:
- lib/redtastic/script_manager.rb
Class Method Summary collapse
- .flush_scripts ⇒ Object
- .load_scripts(script_path) ⇒ Object
- .method_missing(method_name, *args) ⇒ Object
- .to_ary ⇒ Object
Class Method Details
.flush_scripts ⇒ Object
22 23 24 25 |
# File 'lib/redtastic/script_manager.rb', line 22 def flush_scripts @stored_methods = nil Redtastic::Connection.redis.script(:flush) end |
.load_scripts(script_path) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/redtastic/script_manager.rb', line 4 def load_scripts(script_path) @stored_methods = HashWithIndifferentAccess.new unless @stored_methods.is_a?(Hash) Dir["#{script_path}/*.lua"].map do |file| method = File.basename(file, '.*') unless @stored_methods.key?(method) @stored_methods[method] = Redtastic::Connection.redis.script(:load, `cat #{file}`) end end end |
.method_missing(method_name, *args) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/redtastic/script_manager.rb', line 14 def method_missing(method_name, *args) if @stored_methods.is_a?(Hash) && @stored_methods.key?(method_name) Redtastic::Connection.redis.evalsha(@stored_methods[method_name], *args) else fail("Could not find script: #{method_name}.lua") end end |
.to_ary ⇒ Object
27 28 29 |
# File 'lib/redtastic/script_manager.rb', line 27 def to_ary nil end |