Skip to content

Instantly share code, notes, and snippets.

@justfalter
Created June 27, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justfalter/adc4f0d61f34a43a8bc5 to your computer and use it in GitHub Desktop.
Save justfalter/adc4f0d61f34a43a8bc5 to your computer and use it in GitHub Desktop.
Hashie IndifferentAccess assignment issue
require 'hashie'
require 'pp'
class A < Hashie::Dash
include Hashie::Extensions::IndifferentAccess
property :some_array
property :some_hash
property :some_object
end
class B < Hashie::Dash
property :some_array
property :some_hash
property :some_object
end
hash_value = {}
array_value = []
object = Object.new
a = A.new
b = B.new
a.some_hash = hash_value
a.some_array = array_value
a.some_object = object
b.some_hash = hash_value
b.some_array = array_value
b.some_object = object
pp [:a_hash, hash_value.object_id == a.some_hash.object_id]
pp [:a_array, array_value.object_id == a.some_array.object_id]
pp [:a_object, object.object_id == a.some_object.object_id]
pp [:b_hash, hash_value.object_id == b.some_hash.object_id]
pp [:b_array, array_value.object_id == b.some_array.object_id]
pp [:b_object, object.object_id == b.some_object.object_id]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment