Class: Spina::Parts::StreamField
- Inherits:
-
Base
- Object
- Base
- Spina::Parts::StreamField
- Includes:
- AttrJson::NestedAttributes
- Defined in:
- app/models/spina/parts/stream_field.rb
Class Method Summary collapse
- .component_types ⇒ Object
-
.register_component(label, klass) ⇒ Object
label - human-readable string shown in the “Add Block” menu klass - part class or fully-qualified string name.
- .unregister_component(label) ⇒ Object
Class Method Details
.component_types ⇒ Object
16 17 18 |
# File 'app/models/spina/parts/stream_field.rb', line 16 def component_types @component_types.dup.freeze end |
.register_component(label, klass) ⇒ Object
label - human-readable string shown in the “Add Block” menu klass - part class or fully-qualified string name
22 23 24 25 26 27 |
# File 'app/models/spina/parts/stream_field.rb', line 22 def register_component(label, klass) class_name = klass.is_a?(Class) ? klass.name : klass.to_s raise ArgumentError, "label must be a non-empty String" if label.blank? raise ArgumentError, "klass must resolve to a class name" if class_name.blank? @component_types[label] = class_name end |
.unregister_component(label) ⇒ Object
29 30 31 |
# File 'app/models/spina/parts/stream_field.rb', line 29 def unregister_component(label) @component_types.delete(label) end |