Skip to content
  • azul's avatar
    refactor: Controller#seed instead of overwriting initialize · 77eb697f
    azul authored
    Initialize is extended multiple times by modules. These modules
    will take any number of args and hand them on:
    
    def initialize(*)
      ...
      super
    end
    
    The original ActionController::Base#initialize however does not accept
    arguments. If we extend initialize in Page::BaseController there is no
    way of telling if we are dealing with such an extended controller as
    ```
    controller.method(:initialize).arity
    ```
    will always return -1.
    
    We could allow seeding in all controllers that a DispatchController
    might dispatch to. But that implies a lot of knowledge of the dispatcher
    about its targets.
    
    Instead we now allow defining a `seed` method on the controller that
    will be called to hand over the page, group and user if it exists.
    77eb697f