class Persistent💎::Dmndifier
Constants
- DEFAULT_OPTIONS
Public Class Methods
[](arg, options = DEFAULT_OPTIONS)
click to toggle source
# File lib/persistent_dmnd/dmndifier.rb, line 49 def self.[](arg, options = DEFAULT_OPTIONS) options = DEFAULT_OPTIONS.merge(options) case when arg.respond_to?(:to_💎) arg.to_💎 when arg.respond_to?(:to_dmnd) arg.to_dmnd when arg.respond_to?(:to_hash) h💎[arg.to_hash] when arg.is_a?(Hamster::Set) || arg.is_a?(Hamster::SortedSet) s💎[*arg.to_a] when arg.respond_to?(:to_ary) a💎[*arg.to_ary] when defined?(Concurrent::Tuple) && arg.is_a?(Concurrent::Tuple) a💎[*arg.to_a] when arg.respond_to?(:to_set) s💎[*arg.to_set.to_a] when defined?(Concurrent::Map) && arg.is_a?(Concurrent::Map) h💎[Persistent💎::Ruby19And20Support.enumerable_to_h(arg.enum_for(:each_pair))] when arg.respond_to?(:each_pair) h💎[Persistent💎::Ruby19And20Support.enumerable_to_h(arg.each_pair)] else options.fetch(:on_unknown).call(arg) end end