Skip to content

Instantly share code, notes, and snippets.

@bryanp
Created February 12, 2017 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanp/6bd53043c703629f51edc681a8015260 to your computer and use it in GitHub Desktop.
Save bryanp/6bd53043c703629f51edc681a8015260 to your computer and use it in GitHub Desktop.
Pakyow 1.0 Loader Example
module Pakyow
class App
load :resources, with: Loaders::Resource
end
module Loaders
class Resource < Base
location :resources
def initialize(filename, resource)
@filename = filename
@resource = resource
# warn if @resource.name 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
end
def valid?
# valdate that:
# @resource is a Router subclass
# @resource expanded the resource template
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment