diff --git a/lib/flex_commerce_api/api_base.rb b/lib/flex_commerce_api/api_base.rb index ec27947..448a9ed 100644 --- a/lib/flex_commerce_api/api_base.rb +++ b/lib/flex_commerce_api/api_base.rb @@ -120,6 +120,14 @@ def template_attribute(key) end end + def cache_key + if respond_to?(:id) && respond_to?(:updated_at) && id && updated_at + [self.class.name, id, updated_at.to_datetime.utc.to_i.to_s].join("/") + else + raise NotImplementedError, "This model doesn't have an id/updated_at field, so requires custom #cache_key implementation" + end + end + def method_missing(method, *args) if relationships and relationships.has_attribute?(method) super