Sha256: 0a3c5b8379a3450056b460ef82d0769d2b62d94c0952398118bfdf8c52b7b2e3

Contents?: true

Size: 584 Bytes

Versions: 29

Compression:

Stored size: 584 Bytes

Contents

# frozen_string_literal: true

module CKEditor5::Rails
  module Context
    class PresetSerializer
      def initialize(preset)
        @preset = preset
      end

      def to_attributes
        {
          plugins: serialize_plugins,
          config: serialize_config
        }
      end

      private

      delegate :config, to: :@preset

      def serialize_plugins
        (config[:plugins] || []).map { |plugin| Editor::PropsBasePlugin.normalize(plugin).to_h }.to_json
      end

      def serialize_config
        config.except(:plugins).to_json
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
ckeditor5-1.19.5 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.19.4 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.19.3 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.19.2 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.19.1 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.19.0 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.18.3 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.18.1 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.18.0 lib/ckeditor5/rails/context/preset_serializer.rb