module HasWhatnot extend ActiveSupport::Concern included do def whatnot @whatnot ||= super.is_a?(Hash) ? super.deep_symbolize_keys! : nil end def tags whatnot[:tags] ? whatnot[:tags] : [] end def where_has_tag(tag) where("whatnot->'tags' ? :tag", tag: tag) end end end