Skip to content

Accepting Strings as hash keys

Latest

Choose a tag to compare

@pote pote released this 13 Dec 17:46
· 6 commits to master since this release

Thanks to @zspackett triggering the need for this feature hashifiable now supports using Strings as keys for the hash representation of your objects!

class TestUser < Struct.new(:id, :name, :credit_card, :secret_token, :quote)
  extend Hashifiable
  hashify :id,
          :name,
          'quote',
          'random' => Proc.new { [1, 2, 3].sample },
end

Thanks to @foca and @inkel for input on this feature!