Request stack information and store in cache

 @return [TrueClass]
960246
def fetch_stacks(stack_id = nil)
      cache.locked_action(:stacks_lock) do
        logger.info "Lock aquired for stack update. Requesting stacks from upstream. (#{Thread.current})"
        if stack_id
          single_stack = connection.stacks.get(stack_id)
          stacks = single_stack ? {single_stack.id => single_stack} : {}
        else
          stacks = Hash[
            connection.stacks.reload.all.map do |stack|
              [stack.id, stack.attributes]
            end
          ]
        end
        if cache[:stacks].value
          existing_stacks = MultiJson.load(cache[:stacks].value)
          # Force common types
          stacks = MultiJson.load(MultiJson.dump(stacks))
          if stack_id
            stacks = existing_stacks.to_smash.deep_merge(stacks)
          else
            # Remove stacks that have been deleted
            stale_ids = existing_stacks.keys - stacks.keys
            stacks = existing_stacks.to_smash.deep_merge(stacks)
            stale_ids.each do |stale_id|
              stacks.delete(stale_id)
            end
          end
        end
        cache[:stacks].value = stacks.to_json
        logger.info "Stack list has been updated from upstream and cached locally"
      end
      @initial_fetch_complete = true
    end
1288095
def current_scope(klass = nil)
      if klass && Thread.current[CURRENT_SCOPE_KEY].respond_to?(:keys)
        Thread.current[CURRENT_SCOPE_KEY][
            Thread.current[CURRENT_SCOPE_KEY].keys.find { |k| k <= klass }
        ]
      else
        Thread.current[CURRENT_SCOPE_KEY]
      end
    end
1313406
def get!(path, extra=nil, params={})
      path, extra, params = normalize path, extra, params
      key = cache_key path, extra, params

      @last_payload = cache.get key do
        http_get(path, extra, params)
      end

      @last_url = @last_payload.request.last_uri.to_s
      @last_payload
    end
454053
def reload!(print = true)
      puts "Reloading..." if print
      Rails.application.reloader.reload!
      true
    end
1079399
def reset_cache!
      return unless Praxis::Blueprint.caching_enabled?

      Praxis::Blueprint.cache = Hash.new do |hash, key|
        hash[key] = Hash.new
      end
    end
656632
def awesome_active_record_class(object)
      return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:columns) || object.to_s == 'ActiveRecord::Base'
      return awesome_class(object) if object.respond_to?(:abstract_class?) && object.abstract_class?

      data = object.columns.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
        hash[c.name.to_sym] = c.type
        hash
      end

      name = "class #{awesome_simple(object.to_s, :class)}"
      base = "< #{awesome_simple(object.superclass.to_s, :class)}"

      [name, base, awesome_hash(data)].join(' ')
    end
883422
def page_cache
      @page_cache ||= Hash.new { |hash,key| hash[key] = page(key.to_i) }
    end
252028
def seed_cache?
        cached.nil? || @options.force? || (cached.is_a?(CachedResult) && !@options.count_only? && !cached.has_ids? && cached.klass != NilClass)
      end
809570
def gather_master_data(stackname)
      response = fetch_master_data(stackname)
      children = response.delete('children') || []
      result = { stackname => { stack_data: response } }
      children.each do |child|
        result.merge!(gather_master_data(child['name']))
      end
      result
    end
213748
def cache(self):
        
        self.is_cached = True
        self.persist(StorageLevel.MEMORY_ONLY)
        return self
3985
def stack_push(o)

      return stack_push(o.to_lua) if o.respond_to?(:to_lua)

      case o

      when NilClass then Lib.lua_pushnil(@pointer)

      when TrueClass then Lib.lua_pushboolean(@pointer, 1)
      when FalseClass then Lib.lua_pushboolean(@pointer, 0)

      when Integer then Lib.lua_pushinteger(@pointer, o)
      when Float then Lib.lua_pushnumber(@pointer, o)

      when String then Lib.lua_pushlstring(@pointer, o, o.bytesize)
      when Symbol then Lib.lua_pushlstring(@pointer, o.to_s, o.to_s.bytesize)

      when Hash then stack_push_hash(o)
      when Array then stack_push_array(o)

      else raise(
        ArgumentError.new(
          "don't know how to pass Ruby instance of #{o.class} to Lua"))
      end
    end
406057
def reload!(controller)
      return controller unless defined?(Rails) and !Rails.configuration.cache_classes
      # we don't reload our own controller as we assume it provide as 'library'
      unless controller.name == "WebsocketRails::InternalController"
        class_name = controller.name
        filename = class_name.underscore
        load "#{filename}.rb"
        return class_name.constantize
      end

      return controller
    end
1286411
def current
      response = request(:get_all_current)
      handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }
      initialize_items
      get_data_for_handles(handles)

      self
    end
667409
def refresh!
      raise UnknownObject, self.name unless self.exists?
      h = Rudy::Metadata.get self.name
      return false if h.nil? || h.empty?
      obj = self.from_hash(h)
      obj.postprocess
      obj
    end
1043829
def stack(new_scope = nil)
      old_stack_used = @this_stack_used
      if new_scope
        push(new_scope)
        @this_stack_used = true
      else
        @this_stack_used = false
      end

      yield
    ensure
      pop if @this_stack_used
      @this_stack_used = old_stack_used
    end
1299233
def prepare!(env)
      @env      = env
      @request  = Rack::Request.new(env)
      @response = Rack::Response.new
      @headers  = @response.header
      @params   = @request.GET.merge(@request.POST)
      @params.default_proc = proc do |hash, key|
        hash[key.to_s] if Symbol === key
      end
    end
1028056
def flush_cache
      Rails.cache.delete([self.class.name, symbol_was.to_s])
      Rails.cache.delete([self.class.name, id])
    end