couchbase/couchbase-ruby-model — pull request #2 by mje113 (2012-12-07 17:50:52+00:00)
Title: Provide proper attribute inheritance when subclassing Models

Currently, Couchbase::Model stores attributes (and views) in a class variable set to a mutable hash. This breaks the expected subclass attribute inheritance behavior that ActiveModel provides.

Example:
```ruby
class A < Couchbase::Model
attribute :one
end

class B < A
attribute :two
end

B.attributes #=> {:one => nil, :two => nil}
A.attributes #=> {:one => nil, :two => nil}
B.attributes.object_id == A.attributes.object_id #=> true
```

This patch enables proper inheritance when ::Rails is present by using Class#class_attribute and detecting subclass additions to attribute:
```ruby
class A < Couchbase::Model
attribute :one
end

class B < A
attribute :two
end

A.attributes #=> {:one => nil}
B.attributes #=> {:one => nil, :two => nil}
B.attributes.object_id != A.attributes.object_id #=> true