Allow to use non-proc object in cache_path option - #2
Merged
Conversation
You can use :cache_path option with object that respond to #call method.
Before this patch ActionCacheFilter check that object respond to #call
method and execute #instance_exec on controller instance. It was strange
because #instance_exec method can work only with Proc objects.
When you pass Proc object to :cache_option it will be execute #instance_exec
with this Proc otherwise when object is respond to #call method will be called
on this object.
class CachePath
def call(controller)
controller.id
end
end
class TestController < ApplicationController
caches_action :index, :cache_path => CachePath.new
def index; end
end
Contributor
|
It seems good to me 👍 @rafaelfranca @carlosantoniodasilva WDYT? |
Member
There was a problem hiding this comment.
How about: If an object that responds to <tt>call</tt> is given, it'll be called with the current controller instance.
Member
|
Seems fine I guess. Is it worth to start its own changelog maybe? |
Member
|
I think is better to release the version 1.0.0 before to pull this in |
Contributor
|
1.0.0 is released. |
Member
|
Right. @frodsan can you merge this in and start the CHANGELOG? |
Contributor
|
@rafaelfranca Sure, but what about @carlosantoniodasilva comments? |
Member
|
You can merge and apply those changes after |
frodsan
pushed a commit
that referenced
this pull request
Mar 1, 2013
Allow to use non-proc object in cache_path option
Contributor
|
Ok, no problem. @LTe Thanks! 😄 |
frodsan
pushed a commit
that referenced
this pull request
Mar 1, 2013
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You can use :cache_path option with object that respond to #call method.
Before this patch ActionCacheFilter check that object respond to #call
method and execute #instance_exec on controller instance. It was strange
because #instance_exec method can work only with Proc objects.
When you pass Proc object to :cache_option it will be execute #instance_exec
with this Proc otherwise when object is respond to #call method will be called
on this object.