class CartridgeCache

Constants

FRAMEWORK_CART_NAMES

Public Class Methods

cartridge_names(cart_type=nil) click to toggle source
# File lib/stickshift-controller/app/models/cartridge_cache.rb, line 30
def self.cartridge_names(cart_type=nil)
  cart_names = cartridges.map{|c| c.name}

  if cart_type == 'standalone'
    return cart_names & FRAMEWORK_CART_NAMES
  elsif cart_type == 'embedded'
    return (cart_names - FRAMEWORK_CART_NAMES)
  else
    return cart_names
  end
end
cartridges() click to toggle source
# File lib/stickshift-controller/app/models/cartridge_cache.rb, line 22
def self.cartridges
  get_cached("all_cartridges", :expires_in => 1.day) {StickShift::ApplicationContainerProxy.find_one().get_available_cartridges}
end
find_cartridge(capability) click to toggle source
# File lib/stickshift-controller/app/models/cartridge_cache.rb, line 42
def self.find_cartridge(capability)
  carts = self.cartridges
  carts.each do |cart|
    return cart if cart.all_capabilities.include?(capability)
    return cart if cart.name == capability
  end
  return nil
end
get_cached(key, opts={}) { || ... } click to toggle source
# File lib/stickshift-controller/app/models/cartridge_cache.rb, line 2
def self.get_cached(key, opts={})
  unless Rails.configuration.action_controller.perform_caching
    if block_given?
      return yield
    end
  end

  val = Rails.cache.read(key)
  unless val
    if block_given?
      val = yield
      if val
        Rails.cache.write(key, val, opts)
      end
    end
  end

  return val
end