Sha256: aed2e26fa9b7ca1fa07f088e79558bb62787fcc8c82de8653091173a3ff81bf4
Contents?: true
Size: 679 Bytes
Versions: 13
Compression:
Stored size: 679 Bytes
Contents
require 'sequel' class Cranium::Sequel::Hash < Hash def qualify(options) invalid_options = options.keys - [:keys_with, :values_with] raise ArgumentError, "Unsupported option for qualify: #{invalid_options.first}" unless invalid_options.empty? Hash[qualify_fields(options[:keys_with], keys).zip qualify_fields(options[:values_with], values)] end def qualified_keys(qualifier) qualify_fields qualifier, keys end def qualified_values(qualifier) qualify_fields qualifier, values end private def qualify_fields(qualifier, fields) return fields if qualifier.nil? fields.map { |field| Sequel.qualify qualifier, field } end end
Version data entries
13 entries across 13 versions & 1 rubygems