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

receives method should be defined as a singleton method on the singleton class #401

Closed
catmando opened this issue Apr 6, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@catmando
Copy link
Contributor

catmando commented Apr 6, 2021

The receives method can be used as a class method or an instance method, but not as singleton method on the class:

class SomeComponent < HyperComponent
  after_mount do
    receives(SomeOperation) { ...self is an instance in here... } 
  end
  receives(SomeOperation) { ... self is the class in here ... }  
  class << self 
    def some_class_method
    end 
    receives(SomeOperation) { ... doesn't work! ... }
  end
end

The third case should just set up the receiver at the class level so that things read better.

Otherwise, if you are defining a bunch of class methods, and need to have a receiver at the class level, you
have to step outside the singleton class, to set the receiver up.

@catmando catmando added the enhancement New feature or request label Apr 6, 2021
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
Development

No branches or pull requests

1 participant