Module: TabsTabs::Config
Instance Method Summary collapse
- #decimal_precision ⇒ Object
- #decimal_precision=(precision) ⇒ Object
- #expiration_settings ⇒ Object
- #expires?(resolution) ⇒ Boolean
- #expires_in(resolution) ⇒ Object
- #prefix ⇒ Object
- #prefix=(arg) ⇒ Object
- #redis ⇒ Object
- #redis=(arg) ⇒ Object
- #register_resolution(klass) ⇒ Object
- #reset_expirations ⇒ Object
- #set_expirations(resolution_hash) ⇒ Object
- #unregister_resolutions(*resolutions) ⇒ Object
Instance Method Details
#decimal_precision ⇒ Object
5 6 7 |
# File 'lib/tabs_tabs/config.rb', line 5 def decimal_precision @decimal_precision ||= 5 end |
#decimal_precision=(precision) ⇒ Object
9 10 11 |
# File 'lib/tabs_tabs/config.rb', line 9 def decimal_precision=(precision) @decimal_precision = precision end |
#expiration_settings ⇒ Object
41 42 43 |
# File 'lib/tabs_tabs/config.rb', line 41 def expiration_settings @expiration_settings ||= {} end |
#expires?(resolution) ⇒ Boolean
52 53 54 |
# File 'lib/tabs_tabs/config.rb', line 52 def expires?(resolution) expiration_settings.has_key?(resolution) end |
#expires_in(resolution) ⇒ Object
56 57 58 |
# File 'lib/tabs_tabs/config.rb', line 56 def expires_in(resolution) expiration_settings[resolution] end |
#prefix ⇒ Object
29 30 31 |
# File 'lib/tabs_tabs/config.rb', line 29 def prefix @prefix end |
#prefix=(arg) ⇒ Object
25 26 27 |
# File 'lib/tabs_tabs/config.rb', line 25 def prefix=(arg) @prefix = arg end |
#redis ⇒ Object
21 22 23 |
# File 'lib/tabs_tabs/config.rb', line 21 def redis @redis ||= Redis.new end |
#redis=(arg) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/tabs_tabs/config.rb', line 13 def redis=(arg) if arg.is_a?(Redis) @redis = arg else @redis = Redis.new(arg) end end |
#register_resolution(klass) ⇒ Object
33 34 35 |
# File 'lib/tabs_tabs/config.rb', line 33 def register_resolution(klass) TabsTabs::Resolution.register(klass) end |
#reset_expirations ⇒ Object
60 61 62 |
# File 'lib/tabs_tabs/config.rb', line 60 def reset_expirations @expiration_settings = {} end |
#set_expirations(resolution_hash) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/tabs_tabs/config.rb', line 45 def set_expirations(resolution_hash) resolution_hash.each do |resolution, expires_in_seconds| raise TabsTabs::ResolutionMissingError.new(resolution) unless TabsTabs::Resolution.all.include? resolution expiration_settings[resolution] = expires_in_seconds end end |
#unregister_resolutions(*resolutions) ⇒ Object
37 38 39 |
# File 'lib/tabs_tabs/config.rb', line 37 def unregister_resolutions(*resolutions) TabsTabs::Resolution.unregister(resolutions) end |