Sha256: 18a9653313cfa7838a5333b092d5f1dd3df1f6a2a4c48a70bf39a281a2733d0d
Contents?: true
Size: 618 Bytes
Versions: 5
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true module Remocon module ConditionSorter CONDITION_KEYS = %w(name expression tagColor).freeze def comparator_of_condition_keys(left, right) (CONDITION_KEYS.index(left) || 10_000) <=> (CONDITION_KEYS.index(right) || 10_000) end def sort_conditions(conditions) conditions .sort_by { |e| e["name"] || e[:name] } .map do |e| e.stringify_keys .sort { |(a, _), (b, _)| comparator_of_condition_keys(a, b) } .each_with_object({}) { |(k, v), acc| acc[k] = v } .with_indifferent_access end end end end
Version data entries
5 entries across 5 versions & 1 rubygems