apotonick / disposable

Decorators on top of your ORM layer.
MIT License
171 stars 39 forks source link

Add :accessor for avoiding defining accessors #42

Open janko opened 8 years ago

janko commented 8 years ago

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 commented 8 years ago

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

apotonick commented 8 years ago

I might have another use case for that...

janko commented 8 years ago

Sure thing!