Sha256: 3f6a425336b30fd677e1975a7b279bb54106d91062340b710a9c4baac2bcdbc6
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
begin require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/deep_merge' rescue LoadError class Hash unless {}.respond_to?(:slice) def slice(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if key?(k) } end end unless {}.respond_to?(:slice!) def slice!(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) omit = slice(*self.keys - keys) hash = slice(*keys) hash.default = default hash.default_proc = default_proc if default_proc replace(hash) omit end end end end class Array unless [].respond_to?(:extract_options!) def extract_options! if last.is_a?(Hash) && last.instance_of?(Hash) pop else {} end end end end class String unless ''.respond_to?(:classify) def classify camelize(sub(/.*\./, '')) end end unless ''.respond_to?(:camelize) def camelize(uppercase_first_letter = true) string = self string = if uppercase_first_letter string.sub(/^[a-z\d]*/) { $&.capitalize } else string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } end string.gsub!(%r{(?:_|(\/))([a-z\d]*)}i) do "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" end string.gsub!(%r{/}, '::') string end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-5.0.2 | lib/sidekiq_unique_jobs/core_ext.rb |
sidekiq-unique-jobs-5.0.1 | lib/sidekiq_unique_jobs/core_ext.rb |
sidekiq-unique-jobs-5.0.0 | lib/sidekiq_unique_jobs/core_ext.rb |