Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add :accessor for avoiding defining accessors#42

Open
janko wants to merge 1 commit into
apotonick:masterapotonick/disposable:masterfrom
janko:accessorjanko/disposable:accessorCopy head branch name to clipboard
Open

Add :accessor for avoiding defining accessors#42
janko wants to merge 1 commit into
apotonick:masterapotonick/disposable:masterfrom
janko:accessorjanko/disposable:accessorCopy head branch name to clipboard

Conversation

@janko

@janko janko commented May 8, 2016

Copy link
Copy Markdown

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

janko commented May 8, 2016

Copy link
Copy Markdown
Author

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
Copy Markdown
Owner

I might have another use case for that...

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

janko commented May 9, 2016

Copy link
Copy Markdown
Author

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.