Class: Wolverine
- Inherits:
-
Object
show all
- Defined in:
- lib/wolverine.rb,
lib/wolverine/script.rb,
lib/wolverine/version.rb,
lib/wolverine/lua_error.rb,
lib/wolverine/configuration.rb,
lib/wolverine/path_component.rb
Defined Under Namespace
Classes: Configuration, LuaError, PathComponent, Script
Constant Summary
collapse
- VERSION =
"0.3.1"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config = nil) ⇒ Wolverine
Returns a new instance of Wolverine.
56
57
58
|
# File 'lib/wolverine.rb', line 56
def initialize(config = nil)
@config = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/wolverine.rb', line 73
def method_missing sym, *args
if sym[0] == '_'
super
else
root_directory.send(sym, *args)
end
rescue PathComponent::MissingTemplate
super
end
|
Class Method Details
.cached_methods ⇒ Object
91
92
93
|
# File 'lib/wolverine.rb', line 91
def self.cached_methods
@cached_methods ||= Hash.new
end
|
Returns the configuration object for reading and writing configuration values.
15
16
17
|
# File 'lib/wolverine.rb', line 15
def self.config
@config ||= Configuration.new
end
|
.enable_statsd! ⇒ Object
30
31
32
|
# File 'lib/wolverine.rb', line 30
def self.enable_statsd!
@statsd_enabled = true
end
|
.method_missing(sym, *args) ⇒ PathComponent, Object
50
51
52
53
54
|
# File 'lib/wolverine.rb', line 50
def self.method_missing sym, *args
root_directory.send(sym, *args)
rescue PathComponent::MissingTemplate
super
end
|
.redis ⇒ Redis
Provides access to the redis connection currently in use by Wolverine.
22
23
24
|
# File 'lib/wolverine.rb', line 22
def self.redis
config.redis
end
|
.reset! ⇒ void
This method returns an undefined value.
Resets all the scripts cached by Wolverine. Scripts are lazy-loaded and cached in-memory, so if a file changes on disk, it will be necessary to manually reset the cache using reset!.
39
40
41
42
|
# File 'lib/wolverine.rb', line 39
def self.reset!
@root_directory = nil
reset_cached_methods
end
|
.reset_cached_methods ⇒ Object
95
96
97
98
99
|
# File 'lib/wolverine.rb', line 95
def self.reset_cached_methods
metaclass = class << self; self; end
cached_methods.each_key { |method| metaclass.send(:undef_method, method) }
cached_methods.clear
end
|
.root_directory ⇒ Object
87
88
89
|
# File 'lib/wolverine.rb', line 87
def self.root_directory
@root_directory ||= PathComponent.new(config.script_path, {:cache_to => self})
end
|
.statsd_enabled? ⇒ Boolean
26
27
28
|
# File 'lib/wolverine.rb', line 26
def self.statsd_enabled?
@statsd_enabled
end
|
Instance Method Details
#config ⇒ Object
60
61
62
|
# File 'lib/wolverine.rb', line 60
def config
@config || self.class.config
end
|
#redis ⇒ Object
64
65
66
|
# File 'lib/wolverine.rb', line 64
def redis
config.redis
end
|
#reset! ⇒ Object
68
69
70
71
|
# File 'lib/wolverine.rb', line 68
def reset!
@root_directory = nil
reset_cached_methods
end
|