キモブロ

Please spy check please, Fucking retard

Hashがもうちょい便利になったHashie::Mashについて

表題。普通にOpenStructでいいんだけど

require 'hashie'
h = Hashie::Mash.new
h.key1 = Hashie::Mash.new
h.key1.key2 = Hashie::Mash.new
h.key1.key2.key3 = :value

p h[:key1][:key2][:key3]
# => :value


末尾に?をつけることでそのメソッドの存在チェックができるのがキュートか

irb> h.key1?
=> true
irb> h.key9?                                                                             
=> false