-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add memoization #4
base: master
Are you sure you want to change the base?
Conversation
This adds memoization and tests.
config.to_prepare do | ||
ActiveSupport.on_load :action_controller do | ||
include KnockoutAssetsHelper | ||
helper_method :knockout_assets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On reload, you presumably want to bust the knockout_assets
cache - will that happen?
module KnockoutAssetsHelper | ||
include ::Memery | ||
|
||
memoize def knockout_assets(options = {}) | ||
options = { | ||
exclude: nil, | ||
preload: true, | ||
include: /.*\.(png|gif|jpg|jpeg|bmp|svg)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these file extensions be anchored to the end of path as /.*\.(png|...|svg)$/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can probably drop the .*
at the start
@@ -0,0 +1,7 @@ | |||
class ApplicationController < ActionController::Base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on the above assets in the GH diff, but if this is a public gem, I don't think we should include other companies' logos
@@ -0,0 +1,2 @@ | |||
<%= knockout_assets %> | |||
<% knockout_assets # Check calling it a second time is memoized %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it valid to call it twice? Why/how does that happen? Should it be an error instead?
This adds memoization and tests.