Class: CKEditor5::Rails::Presets::Manager
- Inherits:
-
Object
- Object
- CKEditor5::Rails::Presets::Manager
- Defined in:
- lib/ckeditor5/rails/presets/manager.rb
Instance Attribute Summary collapse
-
#presets ⇒ Object
(also: #to_h)
readonly
Returns the value of attribute presets.
Instance Method Summary collapse
-
#[](name) ⇒ PresetBuilder?
Get a preset by name.
-
#default ⇒ PresetBuilder?
Get the default preset configuration.
-
#define(name, inherit: true, &block) ⇒ PresetBuilder
Define a new preset configuration.
-
#initialize ⇒ Manager
constructor
Initializes a new Manager instance and sets up the default preset.
-
#override(name, &block) ⇒ Object
(also: #extend)
Override existing preset configuration.
Constructor Details
#initialize ⇒ Manager
Initializes a new Manager instance and sets up the default preset
14 15 16 17 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 14 def initialize @presets = {} define_default_preset end |
Instance Attribute Details
#presets ⇒ Object (readonly) Also known as: to_h
Returns the value of attribute presets.
9 10 11 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 9 def presets @presets end |
Instance Method Details
#[](name) ⇒ PresetBuilder?
Get a preset by name
71 72 73 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 71 def [](name) @presets[name] end |
#default ⇒ PresetBuilder?
Get the default preset configuration
64 65 66 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 64 def default @presets[:default] end |
#define(name, inherit: true, &block) ⇒ PresetBuilder
Define a new preset configuration
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 35 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
Override existing preset configuration
56 57 58 |
# File 'lib/ckeditor5/rails/presets/manager.rb', line 56 def override(name, &block) @presets[name].instance_eval(&block) end |