docbrown/app/models/articles/cached_entity.rb
Michael Kohl 26ee8f194c
Rubocop: Move from OpenStruct to Struct in Organization (#9431)
* Move from OpenStruct to Struct in Organization

* Add data update script

* Introduce Articles::CachedEntity model

* Update data update script for new model

* Fix comment

* Update jbuilder
2020-07-30 21:04:05 +07:00

14 lines
452 B
Ruby

module Articles
# NOTE: articles cache either users or organizations, but they have the same attributes.
CachedEntity = Struct.new(:name, :username, :slug, :profile_image_90, :profile_image_url) do
def self.from_object(object)
new(
object.name,
object.username,
object.respond_to?(:slug) ? object.slug : object.username,
object.profile_image_90,
object.profile_image_url,
)
end
end
end