Skip to content

Instantly share code, notes, and snippets.

@saks
Created February 10, 2011 12:07
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 saks/820421 to your computer and use it in GitHub Desktop.
Save saks/820421 to your computer and use it in GitHub Desktop.
unexpected behavior of #write_inheritable_attribute with Mongoid::Document included
require 'mongoid'
class A
include Mongoid::Document
write_inheritable_attribute :attr_name, 'attr for A'
class_inheritable_reader :attr_name
end
class B < A; end
puts A.attr_name.inspect, B.attr_name.inspect
class A1
write_inheritable_attribute :attr_name, 'attr for A1'
class_inheritable_reader :attr_name
end
class B1 < A1; end
puts A1.attr_name.inspect, B1.attr_name.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment