Module: RedisEval::GeneratorMethods
- Included in:
- RedisEval
- Defined in:
- lib/redis_eval/generator_methods.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/redis_eval/generator_methods.rb', line 34
def method_missing(name, *args, &block)
super unless respond_to?(name)
define_singleton_method(name) do |*a, &b|
script_cache[name.to_s] ||= build(name)
end
send(name, *args, &block)
end
|
Instance Method Details
#build(name) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/redis_eval/generator_methods.rb', line 3
def build(name)
path = case name
when Pathname
name
when String, Symbol
name =~ /\.lua$/ ? pathname(name.to_s) : script_path(name)
else
raise ArgumentError
end
RedisEval::Script.build_from_path(path)
end
|