Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :accessor for avoiding defining accessors #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

janko
Copy link

@janko janko commented May 8, 2016

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.

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
@janko
Copy link
Author

janko commented May 8, 2016

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

@janko janko closed this May 8, 2016
@janko janko deleted the accessor branch May 8, 2016 13:47
@apotonick
Copy link
Owner

I might have another use case for that...

@janko janko restored the accessor branch May 9, 2016 01:36
@janko
Copy link
Author

janko commented May 9, 2016

Sure thing!

@janko janko reopened this May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants