Module: TabsTabs::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/tabs_tabs/config.rb

Instance Method Summary collapse

Instance Method Details

#decimal_precisionObject



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_settingsObject



41
42
43
# File 'lib/tabs_tabs/config.rb', line 41

def expiration_settings
  @expiration_settings ||= {}
end

#expires?(resolution) ⇒ Boolean

Returns:

  • (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

#prefixObject



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

#redisObject



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_expirationsObject



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