Create loaders that load and validate app logic #220

bryanp opened this Issue Feb 14, 2017 · 0 comments


None yet
1 participant

bryanp commented Feb 14, 2017

As discussed, we're moving away from blindly loading everything in app/lib. Instead, app logic will be loaded in a more predictable and organized way. We hope that fewer organizational decisions will make development more approachable to new developers and bring consistency across apps.

App logic (e.g. mappers, models, presenters, resources, routers, and views) will all be loaded in a similar way. On boot, we'll navigate through each destination, loading each file and performing validation. The app won't boot unless validation succeeds.

How validation occurs depends on what is loaded. We want to be reasonably sure that anything we load defines valid state for the app. This will happen via a new concept called loaders. A loader will be defined for each type that specifies 1) where to find the files and 2) validation rules.

Here's what a loader for resources might look like:

module Pakyow
  class App
    load :resources, with: Loaders::Resource

  module Loaders
    class Resource < Base
      location :resources
      def initialize(filename, resource)
        @filename = filename
        @resource = resource
        # warn if does not match @filename
        # we could error here, but a warning seems to make more sense
        # given that everything will work fine (we don't infer meaning
        # from the filename) but we would prefer that the naming
        # convention used makes good sense

      def valid?
        # valdate that:
        # @resource is a Router subclass
        # @resource expanded the resource template
  • Introduce the loader concept to Pakyow::App
  • Define loaders for current features (routers and resources)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment