Sha256: 0112a6f2457e391342ce4734cf3fdb270e310425709953528991cc5424411706
Contents?: true
Size: 742 Bytes
Versions: 26
Compression:
Stored size: 742 Bytes
Contents
module CloudSesame module Query module Node class Sort < Abstract attr_writer :sorting_attributes def sorting_attributes @sorting_attributes ||= deserialize context[:sort] end def [](attribute) sorting_attributes[attribute.to_sym] end def []=(attribute, order = :desc) sorting_attributes[attribute.to_sym] = order.to_sym if order end def compile (result = serialize(sorting_attributes)).empty? ? {} : { sort: result } end private def serialize(hash = {}) hash.to_a.map { |i| i.join(' ') }.join(',') end def deserialize(string) Hash[*((string || "").split(',').map { |i| i.strip.split(' ').map(&:to_sym) }.flatten)] end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems