def operate(operation, atoms)
      # ActiveSupport always available?
      atoms_sorted = ActiveSupport::OrderedHash.new

      # Sort the atoms into the appropriate shards for writing to individual
      # files.
      atoms.each do |atom_name, records|
        (atoms_sorted[encoded_prefix(atom_name)] ||= ActiveSupport::OrderedHash.new)[atom_name] = records
      end

      atoms_sorted.each do |e_p, atoms|
        path = @path.join(e_p.to_s + INDEX_FILE_EXTENSION)

        lock_file(path) do

          if path.exist?
            from_file = path.open do |f|
              Marshal.load(f)
            end
          else
            from_file = ActiveSupport::OrderedHash.new
          end

          atoms = from_file.merge(atoms){ |k,o,n| o.send(operation, n) }

          write_file(path) do |f|
            Marshal.dump(atoms,f)
          end
        end # end lock.

      end
    end
def operate(operation, atoms)
      # ActiveSupport always available?
      atoms_sorted = ActiveSupport::OrderedHash.new

      # Sort the atoms into the appropriate shards for writing to individual
      # files.
      atoms.each do |atom_name, records|
        (atoms_sorted[encoded_prefix(atom_name)] ||= ActiveSupport::OrderedHash.new)[atom_name] = records
      end

      atoms_sorted.each do |e_p, atoms|
        path = @path.join(e_p.to_s + INDEX_FILE_EXTENSION)

        lock_file(path) do

          if path.exist?
            from_file = path.open do |f|
              Marshal.load(f)
            end
          else
            from_file = ActiveSupport::OrderedHash.new
          end

          atoms = from_file.merge(atoms){ |k,o,n| o.send(operation, n) }

          write_file(path) do |f|
            Marshal.dump(atoms,f)
          end
        end # end lock.

      end
    end
Takes atoms and adds or removes them from the index depending on the
 passed operation.