lib/garage/hypermedia_responder.rb in the_garage-2.4.3 vs lib/garage/hypermedia_responder.rb in the_garage-2.4.4

- old
+ new

@@ -22,10 +22,12 @@ # Cache resource encoding result if the resource can be identified. # Garage try to get resource identifier by acccess the resource # `#resource_identifier` or `#id`. def encode_to_hash(resource, *args) if id = get_resource_identifier(resource) - cache_key = "#{resource.class.name}:#{id}" + options = args[0] || {} + selector = options[:selector] || controller.field_selector + cache_key = "#{resource.class.name}:#{id}:#{selector.canonical}" cache[cache_key] ||= _encode_to_hash(resource, *args) else _encode_to_hash(resource, *args) end end