Module: WurflStore

Defined in:
lib/wurfl_store.rb,
lib/wurfl_store/view.rb,
lib/wurfl_store/filter.rb,
lib/wurfl_store/cache_initializer.rb

Defined Under Namespace

Modules: CacheInitializer, Filter, View

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



9
10
11
# File 'lib/wurfl_store.rb', line 9

def cache
  @cache
end

Class Method Details

.cacheObject



10
11
12
# File 'lib/wurfl_store.rb', line 10

def self.cache
  @cache
end

.get_handset(user_agent) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/wurfl_store.rb', line 20

def self.get_handset(user_agent)
  return nil if user_agent.nil?
  CacheInitializer.cache_initialized?
  user_agent.slice!(250..-1)
  handset = @cache.read(user_agent.tr(' ', ''))
  chopped_user_agent = user_agent.chop
  return nil if chopped_user_agent.empty?
  return self.get_handset(chopped_user_agent) if handset.nil?
  return handset
end

.initObject



14
15
16
17
18
# File 'lib/wurfl_store.rb', line 14

def self.init
  @cache = ActiveSupport::Cache.lookup_store(:redis_store)
  # determine if the cache has been initialized with the wurfl
  CacheInitializer.initialize_cache if WurflStore.cache.read('wurfl_initialized').nil?
end