Created
December 18, 2017 07:34
-
-
Save kieraneglin/7758a600060a316cbd4ac43b2ef72b4a to your computer and use it in GitHub Desktop.
punchbox sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post { // The name of this class doesn't matter, nor does the filepath | |
constructor() { | |
// Code related to this class' setup. Not required for Punchbox to run | |
} | |
controller() { | |
// Code within here will run on every action of the controller | |
} | |
index() { | |
// This code will run on the Posts#index action specifically | |
} | |
account() { | |
// You aren't constrained to using REST actions either | |
// This works with any action defined in your Rails controller | |
} | |
sharedMethod() { | |
// You can have any other methods in here and reference them from other methods in this class! | |
// Just make sure your method names don't conflict with action names | |
} | |
} | |
// Enter the controller name, then the class | |
// The controller name is PascalCase with slashes preserved (see docs) | |
// Notice that the class isn't instantiated. Punchbox handles that | |
Punchbox.on('Posts', Post); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment