Class: CKEditor5::Rails::Editor::PropsPatchPlugin
- Inherits:
-
PropsInlinePlugin
- Object
- PropsBasePlugin
- PropsInlinePlugin
- CKEditor5::Rails::Editor::PropsPatchPlugin
- Defined in:
- lib/ckeditor5/rails/editor/props_patch_plugin.rb
Instance Attribute Summary collapse
-
#max_version ⇒ Object
readonly
Returns the value of attribute max_version.
-
#min_version ⇒ Object
readonly
Returns the value of attribute min_version.
Attributes inherited from PropsInlinePlugin
Attributes inherited from PropsBasePlugin
Class Method Summary collapse
Instance Method Summary collapse
- #applicable_for_version?(editor_version) ⇒ Boolean
-
#initialize(name, code, min_version: nil, max_version: nil) ⇒ PropsPatchPlugin
constructor
A new instance of PropsPatchPlugin.
Methods inherited from PropsInlinePlugin
Methods inherited from PropsBasePlugin
normalize, #preload_assets_bundle, #to_h
Constructor Details
#initialize(name, code, min_version: nil, max_version: nil) ⇒ PropsPatchPlugin
Returns a new instance of PropsPatchPlugin.
10 11 12 13 14 15 16 17 |
# File 'lib/ckeditor5/rails/editor/props_patch_plugin.rb', line 10 def initialize(name, code, min_version: nil, max_version: nil) super(name, code) @min_version = min_version && CKEditor5::Rails::Semver.new(min_version) @max_version = max_version && CKEditor5::Rails::Semver.new(max_version) compress! end |
Instance Attribute Details
#max_version ⇒ Object (readonly)
Returns the value of attribute max_version.
8 9 10 |
# File 'lib/ckeditor5/rails/editor/props_patch_plugin.rb', line 8 def max_version @max_version end |
#min_version ⇒ Object (readonly)
Returns the value of attribute min_version.
8 9 10 |
# File 'lib/ckeditor5/rails/editor/props_patch_plugin.rb', line 8 def min_version @min_version end |
Class Method Details
.applicable_for_version?(editor_version, min_version: nil, max_version: nil) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ckeditor5/rails/editor/props_patch_plugin.rb', line 19 def self.applicable_for_version?(editor_version, min_version: nil, max_version: nil) return true if min_version.nil? && max_version.nil? current_version = CKEditor5::Rails::Semver.new(editor_version) min_check = min_version.nil? || current_version >= CKEditor5::Rails::Semver.new(min_version) max_check = max_version.nil? || current_version <= CKEditor5::Rails::Semver.new(max_version) min_check && max_check end |
Instance Method Details
#applicable_for_version?(editor_version) ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/ckeditor5/rails/editor/props_patch_plugin.rb', line 30 def applicable_for_version?(editor_version) self.class.applicable_for_version?( editor_version, min_version: @min_version&.to_s, max_version: @max_version&.to_s ) end |