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 more delegation targets to Rails/Delegate #912

Closed
vlad-pisanov opened this issue Jan 15, 2023 · 0 comments · Fixed by #1438
Closed

Add more delegation targets to Rails/Delegate #912

vlad-pisanov opened this issue Jan 15, 2023 · 0 comments · Fixed by #1438
Labels
enhancement New feature or request

Comments

@vlad-pisanov
Copy link
Contributor

Currently, Rails/Delegate recommends delegate :foo, to: :obj for obj.foo, however delegate supports several other targets, such as delegation to the current class or constant:

class C
  # def foo
  #   self.class.foo
  # end
  delegate :foo, to: :class

  # def bar
  #   CONST.bar
  # end
  delegate :bar, to: :CONST

  # def baz
  #   @inst_obj.baz
  # end
  delegate :baz, to: :@inst_obj

  # def qux
  #   @@class_obj.qux
  # end
  delegate :qux, to: :@@class_obj
end
@koic koic added the enhancement New feature or request label Jan 15, 2023
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 9, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 9, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 10, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 13, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 13, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 13, 2025
…tion for `self.class`, constants, instance variables, and class variables
ydakuka added a commit to ydakuka/rubocop-rails that referenced this issue Feb 13, 2025
…tion for `self.class`, constants, instance variables, and class variables
koic added a commit that referenced this issue Feb 13, 2025
…-to-rails-delegate

[Fix #912] Enhance `Rails/Delegate` by adding delegation detection for `self.class`, constants, instance variables, and class variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants