Class: Wolverine
- Inherits:
-
Object
- Object
- Wolverine
- 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.5"
Class Method Summary collapse
-
.config ⇒ Wolverine::Configuration
Returns the configuration object for reading and writing configuration values.
- .enable_statsd! ⇒ Object
-
.method_missing(sym, *args) ⇒ PathComponent, Object
Used to handle dynamic accesses to scripts.
-
.redis ⇒ Redis
Provides access to the redis connection currently in use by Wolverine.
-
.reset! ⇒ void
Resets all the scripts cached by Wolverine.
- .statsd_enabled? ⇒ Boolean
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(config = nil) ⇒ Wolverine
constructor
A new instance of Wolverine.
- #method_missing(sym, *args) ⇒ Object
- #redis ⇒ Object
- #reset! ⇒ Object
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 # Disallow access to protected partials (files that begin with _ character) if sym[0] == '_' super else root_directory.send(sym, *args) end rescue PathComponent::MissingTemplate super end |
Class Method Details
.config ⇒ Wolverine::Configuration
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
Used to handle dynamic accesses to scripts. Successful lookups will be cached on the PathComponent object. See Wolverine::PathComponent#method_missing for more detail on how this works.
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 |
.statsd_enabled? ⇒ Boolean
26 27 28 |
# File 'lib/wolverine.rb', line 26 def self.statsd_enabled? defined?(@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.dup 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 |