Sha256: 08efa717098867e37d3bc04e7ac89615e7bd96bebfdc2ed8a5a957e492847169
Contents?: true
Size: 1.01 KB
Versions: 16
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module FmRest module Spyke module Model module GlobalFields extend ::ActiveSupport::Concern FULLY_QUALIFIED_FIELD_NAME_MATCHER = /\A[^:]+::[^:]+\Z/.freeze class_methods do def set_globals(values_hash) connection.patch(FmRest::V1.globals_path, { globalFields: normalize_globals_hash(values_hash) }) end private def normalize_globals_hash(hash) hash.each_with_object({}) do |(k, v), normalized| if v.kind_of?(Hash) v.each do |k2, v2| normalized["#{k}::#{k2}"] = v2 end next end unless FULLY_QUALIFIED_FIELD_NAME_MATCHER === k.to_s raise ArgumentError, "global fields must be given in fully qualified format (table name::field name)" end normalized[k] = v end end end end end end end
Version data entries
16 entries across 16 versions & 2 rubygems