Sha256: 8f8bad41b80c64fc92d83166aeade438422458d6c756ee2afdb74bc2f2e8a326

Contents?: true

Size: 580 Bytes

Versions: 6

Compression:

Stored size: 580 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::PropsPlugin.normalize(plugin).to_h }.to_json
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ckeditor5-1.17.4 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.17.3 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.17.2 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.17.1 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.17.0 lib/ckeditor5/rails/context/preset_serializer.rb
ckeditor5-1.16.2 lib/ckeditor5/rails/context/preset_serializer.rb