Class: CKEditor5::Rails::Presets::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/ckeditor5/rails/presets/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



10
11
12
13
# File 'lib/ckeditor5/rails/presets/manager.rb', line 10

def initialize
  @presets = {}
  define_default_preset
end

Instance Attribute Details

#presetsObject (readonly)

Returns the value of attribute presets.



8
9
10
# File 'lib/ckeditor5/rails/presets/manager.rb', line 8

def presets
  @presets
end

Instance Method Details

#[](name) ⇒ Object



36
37
38
# File 'lib/ckeditor5/rails/presets/manager.rb', line 36

def [](name)
  @presets[name]
end

#defaultObject



32
33
34
# File 'lib/ckeditor5/rails/presets/manager.rb', line 32

def default
  @presets[:default]
end

#define(name, inherit: true, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/ckeditor5/rails/presets/manager.rb', line 15

def define(name, inherit: true, &block)
  preset = if inherit && default.present?
             default.clone
           else
             PresetBuilder.new
           end

  preset.instance_eval(&block)
  @presets[name] = preset
end

#override(name, &block) ⇒ Object Also known as: extend



26
27
28
# File 'lib/ckeditor5/rails/presets/manager.rb', line 26

def override(name, &block)
  @presets[name].instance_eval(&block)
end