Skip to content

Instantly share code, notes, and snippets.

@davetapley
Created July 28, 2015 21:32
Show Gist options
  • Save davetapley/ce246e787b241d9d264c to your computer and use it in GitHub Desktop.
Save davetapley/ce246e787b241d9d264c to your computer and use it in GitHub Desktop.
> event.context
=> {"meridien"=>"pm", "contact"=>"jennifer", "contact_id"=>954}
> event.context.class
=> Hash
> event.context['works'] = 'normally'
=> "normally"
> event.context
=> {"meridien"=>"pm", "contact"=>"jennifer", "contact_id"=>954, "works"=>"normally"}
>
> # Now trying HashWithIndifferentAccess
>
> event.context.with_indifferent_access[:works]
=> "normally"
> event.context.with_indifferent_access[:not_so_good] = 'unfortunately'
=> "unfortunately"
> event.context.with_indifferent_access[:not_so_good]
=> nil
> event.context
=> {"meridien"=>"pm", "contact"=>"jennifer", "contact_id"=>954, "works"=>"normally"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment