Uploaded image for project: 'Couchbase Ruby client library'
  1. Couchbase Ruby client library
  2. RCBC-100

Provide proper attribute inheritance when subclassing Couchbase::Model subclasses.

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: Public
    • Labels:
      None

      Description

      (Pull request to fix this can be found here: https://github.com/couchbase/couchbase-ruby-model/pull/2 )

      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:

      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:

      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

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        mje113 Mike Evans created issue -
        Hide
        mje113 Mike Evans added a comment -

        Pull request was updated with an improved patch and passing tests.

        Show
        mje113 Mike Evans added a comment - Pull request was updated with an improved patch and passing tests.
        Show
        avsej Sergey Avseyev added a comment - http://review.couchbase.org/23392
        avsej Sergey Avseyev made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        avsej Sergey Avseyev made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        brett19 Brett Lawson made changes -
        Workflow jira [ 22207 ] Couchbase SDK Workflow [ 44886 ]

          People

          • Assignee:
            avsej Sergey Avseyev
            Reporter:
            mje113 Mike Evans
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes