Recursively goes over all association_cache's from the record and builds the output_hash
 This is the meat-and-potatoes of this tool (plus the the recurse
 method) is where something interesting is happening
515499
def recurse(record)
      raise "This gem only knows how to extract stuff w ActiveRecord" unless record.kind_of? ActiveRecord::Base
      key = record.class.base_class.to_s # the base_class is key for correctly handling STI
      @output_hash[key] ||= Set.new # Set ensures no duplicates
      return if @output_hash[key].include?(record) # Prevent infinite loops as association cache on record with inverse_of will cause this method to stack overflow
      @output_hash[key].add(record)
      record.association_cache.each_pair do |assoc_name,association_def|
        Array(association_def.target).each do |a|
          self.recurse(a)
        end
      end
    end
561883
def list_recursive(list_prefix, parent = '')
      me = File.join(parent, list_prefix)
      result = vault_client.logical.list(me).inject({}) do |hash, item|
        case item
        when /.*\/$/
          hash[item.gsub(/\/$/, '').to_sym] = list_recursive(item, me)
        else
          hash[item.to_sym] = read_data(item, me)
        end
        hash
      end
      result
    end
639833
def chain_enrichments!(agg)
      chain.keys.each do |e|
        enrichment = enrichment_cache(e)
        if enrichment.is_a? Audumbla::FieldEnrichment
          agg = do_field_enrichment(agg, enrichment, chain[e])
        else
          agg = do_basic_enrichment(agg, enrichment, chain[e])
        end
      end
    end
220044
def cached(key, path_info, details, locals)
      name, prefix, partial = path_info

      if key
        @cache.cache(key, name, prefix, partial, locals) do
          yield
        end
      else
        yield
      end
    end
1158105
def update_cloneable_associations
      associations_for_cloning.each do |association|
        type = @klass.reflect_on_association(association)
        through_record = type.through_reflection

        if through_record.present?
          clone_join_relationships(through_record.plural_name)
        else
          clone_has_one_relationship(association,type) if type.macro == :has_one
          clone_has_many_relationships(association) if type.macro == :has_many
        end
      end
    end
10691
def to_hash
      _copy = {}
      @table.each { |key, value| _copy[key] = value.is_a?(HashStruct) ? value.to_hash : value }
      _copy
    end
176607
def clear_query_caches_for_current_thread
      ActiveRecord::Base.connection_handlers.each_value do |handler|
        handler.connection_pool_list.each do |pool|
          pool.connection.clear_query_cache if pool.active_connection?
        end
      end
    end
677679
def build(associations, base_klass)
      associations.map do |name, right|
        if name.is_a? Join
          reflection = find_reflection base_klass, name.name
          reflection.check_validity!
          reflection.check_eager_loadable!

          klass = if reflection.polymorphic?
            name.klass || base_klass
          else
            reflection.klass
          end
          JoinAssociation.new(reflection, build(right, klass), alias_tracker, name.klass, name.type)
        else
          reflection = find_reflection base_klass, name
          reflection.check_validity!
          reflection.check_eager_loadable!

          if reflection.polymorphic?
            raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
          end
          JoinAssociation.new(reflection, build(right, reflection.klass), alias_tracker)
        end
      end
    end
485674
def associations
      @associations ||= Hash[metadata.xpath('//Association').collect do |association_definition|
        [
            association_definition.attributes['Name'].value,
            build_association(association_definition)
        ]
      end]
    end
1321827
def default_cache
      if defined?(Rails) && Rails.respond_to?(:cache)
        Rails.cache
      else
        ::ActiveSupport::Cache::MemoryStore.new
      end
    end
1368344
def load_associated_records
      array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
      @loaded = true
      # we use original to track the state of the collection at start
      @collection = Array.wrap(array).dup
      @original   = Array.wrap(array).freeze
    end
1108926
def find_all_hash(options = {})
      options.assert_valid_keys(:request_level)
      level = find_level(options[:request_level])

      query = self
      level.scope_field.each do |s, args|
        query = args.nil? ? query.send(s) : query = query.send(s, *args)
      end

      records = query.all(:select => level.select_field.join(', '), :include => level.include_field)
      records.map { |r| level.receive(r) }
    end
819514
def cached_belongs_to(*args)
      caches = Array(args[1].delete(:caches))

      association = belongs_to(*args)
      create_cached_belongs_to_child_callbacks(caches, association)
      create_cached_belongs_to_parent_callbacks(caches, association)
    end
1100439
def association_with_root_model(method_name)
      persistor = self.persistor || (respond_to?(:save_to) && save_to && save_to.persistor)

      # Check if we are on the store collection
      if persistor.is_a?(Volt::Persistors::ModelStore) ||
         persistor.is_a?(Volt::Persistors::Page)
        # Get the root node
        root = persistor.try(:root_model)

        # Yield to the block passing in the root node
        yield(root)
      else
        # raise an error about the method not being supported on this collection
        fail "#{method_name} currently only works on the store and page collection (support for other collections coming soon)"
      end
    end
964888
def collectors(self, recurse=True, flags=0):
        
        output = {}
        if recurse and self.inherits():
            schema = orb.system.schema(self.inherits())
            if not schema:
                raise orb.errors.ModelNotFound(schema=self.inherits())
            else:
                iflags = (flags & ~orb.Collector.Flags.Virtual) if flags else ~orb.Collector.Flags.Virtual
                output.update(schema.collectors(recurse=recurse, flags=iflags))
        output.update({c.name(): c for c in self.__collectors.values() if not flags or c.testFlag(flags)})
        return output
833396
def each_child_node_of(o)
      if array_like? o and not record_like? o
        if o.respond_to? :to_hash
          o.each {|k, v| yield Mapping.new(k, v) }
        else
          o.each {|_| yield _ }
        end
      end
    end
661668
def hashify(*args, &block)
      key_value_pairs = args.map {|a| yield(a) }

      # if using Ruby 1.9,
      #   Hash[ key_value_pairs ]
      # is all that's needed, but for Ruby 1.8 compatability, these must
      # be flattened and the resulting array unpacked. flatten(1) only
      # flattens the arrays constructed in the block, it won't mess up
      # any values (or keys) that are themselves arrays/hashes.
      Hash[ *( key_value_pairs.flatten(1) )]
    end