Module: Shitcan
- Defined in:
- lib/shitcan/base.rb,
lib/shitcan/config.rb
Defined Under Namespace
Classes: Config
Class Method Summary collapse
- .cache ⇒ Object
- .config ⇒ Object
- .config=(val) ⇒ Object
-
.exists?(key) ⇒ Boolean
TODO: Is there a faster way to handle exceptions.
- .get(*args) ⇒ Object
- .get_if_exists(key) ⇒ Object
- .set(*args) ⇒ Object
- .skip_if_exists(key) ⇒ Object
Class Method Details
.cache ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/shitcan/base.rb', line 11 def self.cache if config.cache return config.cache else raise ShitCan, 'SHITCAN | NO CONNECTION TO MEMCACHED COULD BE ESTABLISHED!' end end |
.config ⇒ Object
6 7 8 9 |
# File 'lib/shitcan/base.rb', line 6 def self.config return @config if @config @config = Shitcan::Config.new end |
.config=(val) ⇒ Object
2 3 4 |
# File 'lib/shitcan/base.rb', line 2 def self.config=(val) @config = val end |
.exists?(key) ⇒ Boolean
TODO: Is there a faster way to handle exceptions
36 37 38 39 40 41 42 43 |
# File 'lib/shitcan/base.rb', line 36 def self.exists?(key) begin get(key) return true rescue return false end end |
.get(*args) ⇒ Object
23 24 25 |
# File 'lib/shitcan/base.rb', line 23 def self.get(*args) cache.get(*args) end |
.get_if_exists(key) ⇒ Object
27 28 29 |
# File 'lib/shitcan/base.rb', line 27 def self.get_if_exists(key) get(key) if exists?(key) # Fix this! end |
.set(*args) ⇒ Object
19 20 21 |
# File 'lib/shitcan/base.rb', line 19 def self.set(*args) cache.set(*args) end |
.skip_if_exists(key) ⇒ Object
31 32 33 |
# File 'lib/shitcan/base.rb', line 31 def self.skip_if_exists(key) yield unless exists?(key) end |