def accessor(collection, separator = '.')
    ->(*args) do
      key_string = (args.size == 1) ? args.first : args.map(&:to_s).join(separator)
      access(collection, key_string, separator)
    end
  end
def accessor(collection, separator = '.')
    ->(*args) do
      key_string = (args.size == 1) ? args.first : args.map(&:to_s).join(separator)
      access(collection, key_string, separator)
    end
  end
Like access, but returns a lambda that can be used to access a given collection.
 Since lambdas can be called with the subscript operator,
 using it can resemble regular hash or array access.
 If you don't like this you can use '.call' or '.()' instead.

 An example:

 h = { 'h' => ['a', 'b'] }
 accessor = CollectionAccess.accessor(h)
 accessor['h.1']    # => 'b'
 or
 accessor.('h.1')    # => 'b'