Module: ActionController::Base::IdentityMap::InstanceMethods
- Included in:
- ActionController::Base
- Defined in:
- lib/identity_map/action_controller/dispatcher.rb
Instance Method Summary collapse
-
#with_identity_map(fresh = true) ⇒ Object
Execute block with identity map.
-
#without_identity_map ⇒ Object
Temporary disables identity map.
Instance Method Details
#with_identity_map(fresh = true) ⇒ Object
Execute block with identity map.
If it called with true
, then new instance of identity map would be used regardless of any present.
If it called with false
, then it only ensures that identity map created if absent.
Default is true
Typical usage is around filter, which is most times better than direct call.
Usage:
class ThingsController
def action1
with_identity_map do
#some_actions
end
end
#around_filter :with_identity_map, :only => :action2
use_identity_map :only => :action2
def action2
#some_actions
end
end
Method declared as a helper method, so could be used in a views.
31 32 33 34 35 |
# File 'lib/identity_map/action_controller/dispatcher.rb', line 31 def with_identity_map( fresh = true ) ActiveRecord::Base.with_id_map(fresh) { yield } end |
#without_identity_map ⇒ Object
Temporary disables identity map.
Could be used if identity map introduced undesired behaviour.
Usage:
class ThingsController
def action1
without_identity_map do
#some_actions
end
end
around_filter :without_identity_map, :only => :action2
def action2
#some_actions
end
end
Method declared as a helper method, so could be used in a views.
54 55 56 57 58 |
# File 'lib/identity_map/action_controller/dispatcher.rb', line 54 def without_identity_map ActiveRecord::Base.without_id_map { yield } end |