module Cachetastic::Adapters

Public Class Methods

build(klass) click to toggle source

This method will return the appropriate Cachetastic::Adapters::Base class that is defined for the Class passed in. If an adapter has not been defined for the Class than the default adapter is returned.

Examples:

configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
configatron.cachetastic.user.adapter = Cachetastic::Adapters::Memcached
Cachetastic::Adapters.build(User).class # => Cachetastic::Adapters::Memcached
Cachetastic::Adapters.build(Comment).class # => Cachetastic::Adapters::LocalMemory
# File lib/cachetastic/adapters/base.rb, line 16
def build(klass)
  adp = klass.to_configatron(:cachetastic).adapter
  if adp.nil?
    adp = configatron.cachetastic.defaults.adapter
  end
  adp.new(klass)
end