Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Happy to use an &&= operator
class UserDecorator < Draper::Decorator
include Draper::LazyHelpers
delegate_all
class << self
def tagtionary
@tagionary ||= tagtionary!.clone
end
def tagtionary!
tag_ids = User.all.map {|u| u.tag_ids }.flatten.uniq
tags = Tag.find(tag_ids)
out = tags.map{|t| [t.id, t]}.to_h
@tagionary &&= out
out
end
end
def tags
object.tag_ids.map{|t_id| UserDecorator.tagtionary[t_id]}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment