ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:103314] [Ruby master Feature#6470] Make attr_accessor return the list of generated method
       [not found] <redmine.issue-6470.20120520082939.2347@ruby-lang.org>
@ 2021-04-08 18:02 ` get.codetriage
  0 siblings, 0 replies; only message in thread
From: get.codetriage @ 2021-04-08 18:02 UTC (permalink / raw
  To: ruby-core

Issue #6470 has been updated by schneems (Richard Schneeman).


This is implemented https://twitter.com/avdi/status/1380213296108867586. Let's close this ticket! 

:)

----------------------------------------
Feature #6470: Make attr_accessor return the list of generated method
https://bugs.ruby-lang.org/issues/6470#change-91400

* Author: rupert (Robert Pankowecki)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
attr_accesor currently returns nil. It would be more helpful if it return list of generated methods so that it can become an argument to other methods like :private or :protected. That way private accessors can still be defined at top of the class and be private without changing the visibility of next methods. 

```
class Something
  private *attr_accessor :user, :action # IMHO This is nice
  # private attr_accessor :user, :action # <-- would be even better if :private method accepted arrays

  def initialize(user, action)
    self.user   = user
    self.action = action
  end

  def public_method
    user.do_something(action)
  end
end
```

VS

```
class Something
  private; attr_accessor :user, :action; public # IMHO Hack!!

  def initialize(user, action)
    self.user   = user
    self.action = action
  end

  def public_method
    user.do_something(action)
  end
end
```

VS

```
class Something
  def initialize(user, action)
    self.user   = user
    self.action = action
  end

  def public_method
    user.do_something(action)
  end

  private
  attr_accessor :user, :action # IMHO Does not look nice at bottom of the class definition
end
```



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-08 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-6470.20120520082939.2347@ruby-lang.org>
2021-04-08 18:02 ` [ruby-core:103314] [Ruby master Feature#6470] Make attr_accessor return the list of generated method get.codetriage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).