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

Raise exception when injecting into modules #62

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

Commits on Oct 1, 2019

  1. Raise exception when injecting into modules

    To me it happened that I accidentally injected my dependencies into a
    namespace module instead of into a class, like this:
    
      module Operations
        module Articles
          include Import["repositories.articles"]
    
          class Create
            # ...
          end
        end
      end
    
    When I did that, I got a NoMethodError for NilClass somewhere down the
    line. This led me to believe that I've somehow incorrectly passed
    parameters to `Import[]`, and it took me a while to realize what was the
    error.
    
    The error occurred because the downstream code assumes the #initialize
    method will be defined, which is not the case for modules. To improve
    the developer experience, we detect that we're attempting to inject into
    a module and raise an explicit exception.
    janko committed Oct 1, 2019
    Configuration menu
    Copy the full SHA
    733d017 View commit details
    Browse the repository at this point in the history