module JsonbAccessor::Macro::ClassMethods

def _initialize_jsonb_attrs(jsonb_attribute, fields_map, jsonb_attribute_initialization_method_name)

def _initialize_jsonb_attrs(jsonb_attribute, fields_map, jsonb_attribute_initialization_method_name)
  define_method(jsonb_attribute_initialization_method_name) do
    jsonb_attribute_hash = send(jsonb_attribute) || {}
    fields_map.names.each do |field|
      send("#{field}=", jsonb_attribute_hash[field.to_s])
    end
  end
  after_initialize(jsonb_attribute_initialization_method_name)
end