class FMCache::Helper
Public Class Methods
sort(values, ids)
click to toggle source
@param [<Hash>] values @param [<Integer>] ids @return [<Hash>]
# File lib/fmcache/helper.rb, line 14 def sort(values, ids) id_map = ids.map.with_index { |id, i| [id, i] }.to_h values.sort do |a, b| id_map.fetch(a.fetch(:id)) <=> id_map.fetch(b.fetch(:id)) end end
to_fields(field_mask, prefix: [])
click to toggle source
@param [FieldMaskParser::Node] field_mask @param [<Symbol>] prefix @return [<String>]
# File lib/fmcache/helper.rb, line 7 def to_fields(field_mask, prefix: []) field_mask.to_paths(prefix: prefix, sort: false) end