Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/flex_commerce_api/api_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down