disposable icon indicating copy to clipboard operation
disposable copied to clipboard

Add :accessor for avoiding defining accessors

Open janko opened this issue 9 years ago • 3 comments

If we have an accessor defined before declaring a property in an included module, it will get overriden. The :accessor option allows us to specify whether we want Disposable::Twin to define accessors for that property.

module Titleable
  def title
    # ...
  end

  def title=(value)
    # ...
  end
end

class Song < Disposable::Twin
  include Titleable
  property :title, accessor: false
end

I know this is probably a fairly uncommon scenario, but I needed this in Shrine.

janko avatar May 08 '16 13:05 janko

I realized that this is a too specific use case, I just got around it in Shrine by overriding Disposable::Twin.create_accessors.

janko avatar May 08 '16 13:05 janko

I might have another use case for that...

apotonick avatar May 08 '16 22:05 apotonick

Sure thing!

janko avatar May 09 '16 01:05 janko