Class: FMCache::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/fmcache/helper.rb

Class Method Summary collapse

Class Method Details

.sort(values, ids) ⇒ <Hash>

Parameters:

  • values (<Hash>)
  • ids (<Integer>)

Returns:

  • (<Hash>)


14
15
16
17
18
19
# 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: []) ⇒ <String>

Parameters:

  • field_mask (FieldMaskParser::Node)
  • prefix (<Symbol>) (defaults to: [])

Returns:

  • (<String>)


7
8
9
# File 'lib/fmcache/helper.rb', line 7

def to_fields(field_mask, prefix: [])
  field_mask.to_paths(prefix: prefix, sort: false)
end