Skip to content

Commit 6e5f355

Browse files
committed
Better
1 parent e4af564 commit 6e5f355

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/active_model_serializers/model.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@ def self.attributes(*names)
1717
self.attribute_names = attribute_names | names.map(&:to_sym)
1818
end
1919

20-
attributes :id, :cache_key, :updated_at
20+
attributes :id
21+
attr_accessor :updated_at, :cache_key
2122

2223
# Defaults to the downcased model name.
2324
def id
24-
(@id ||= nil) || self.id = self.class.name.downcase
25+
(@id ||= nil) || self.class.name.downcase
2526
end
2627

2728
# Defaults to the downcased model name and updated_at
2829
def cache_key
29-
(@cache_key ||= nil) || self.cache_key = "#{self.class.name.downcase}/#{id}-#{updated_at.strftime('%Y%m%d%H%M%S%9N')}"
30+
(@cache_key ||= nil) || "#{self.class.name.downcase}/#{id}-#{updated_at.strftime('%Y%m%d%H%M%S%9N')}"
3031
end
3132

3233
# Defaults to the time the serializer file was modified.
3334
def updated_at
34-
(@updated_at ||= nil) || self.updated_at = File.mtime(__FILE__)
35+
(@updated_at ||= nil) || File.mtime(__FILE__)
3536
end
3637

3738
attr_reader :errors

0 commit comments

Comments
 (0)