serradura/u-case

Add more methods to Micro::Case::Result quack like a Hash

serradura opened this issue · 1 comments

Definition of Done:

Add these new methods into Micro::Case::Result:

Documentation

Look here to see the implementation of the methods #[] and #values_at().

Below are the places to put the tests to assert these new methods:

Because of the Hash#slice method does not exists in older Ruby versions, we will need to create an util to do this inside of Micro::Case::Result#slice. e.g:

module Micro
  class Case
    module Utils
      def self.slice_hash(hash, keys)
        if Kind::Of::Hash(hash).respond_to?(:slice)
          hash.slice(*keys)
        else
          hash.select { |key, _value| keys.include?(key) }
        end
      end
    end
  end
end

Thanks, @tomascco to help us to release these new features. 👏