Explicitly return on load_resource if resource is already loaded #818

Open
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+5 −0
Diff settings

Always

Just for now

@@ -27,6 +27,7 @@ def load_and_authorize_resource
end
def load_resource
+ return if resource_instance_loaded?
unless skip?(:load)
if load_instance?
self.resource_instance ||= load_resource_instance
@@ -160,6 +161,10 @@ def resource_instance
@controller.instance_variable_get("@#{instance_name}") if load_instance?
end
+ def resource_instance_loaded?
+ !@controller.instance_variable_get("@#{instance_name}").nil?
+ end
+
def collection_instance=(instance)
@controller.instance_variable_set("@#{instance_name.to_s.pluralize}", instance)
end