Class: EmbeddableModelConfig
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- EmbeddableModelConfig
- Defined in:
- app/models/embeddable_model_config.rb
Constant Summary collapse
- IGNORED_ATTRIBUTES =
%w[id created_at updated_at].freeze
- BOOLEAN_ATTRIBUTES =
%w[tree_based? always_display_tag_indicator? embeddable_applet? embeddable_image? requires_rendering?].freeze
Class Method Summary collapse
- .all_embeddable_models ⇒ Object
- .attributes ⇒ Object
- .ckeditor_allowed_content_rules ⇒ Object
- .ckeditor_config ⇒ Object
- .embeddable_applet_models ⇒ Object
- .embeddable_image_models ⇒ Object
- .embeddable_tree_based_models ⇒ Object
- .for_model(embeddable_model) ⇒ Object
Instance Method Summary collapse
Class Method Details
.all_embeddable_models ⇒ Object
26 27 28 |
# File 'app/models/embeddable_model_config.rb', line 26 def self. all.map(&:embeddable_model) end |
.attributes ⇒ Object
20 21 22 23 24 |
# File 'app/models/embeddable_model_config.rb', line 20 def self.attributes @attributes ||= (attribute_names - IGNORED_ATTRIBUTES + BOOLEAN_ATTRIBUTES).map(&:to_sym) end |
.ckeditor_allowed_content_rules ⇒ Object
14 15 16 17 18 |
# File 'app/models/embeddable_model_config.rb', line 14 def self.ckeditor_allowed_content_rules ckeditor_config.map do |selector, content| [selector, content] end.to_h end |
.ckeditor_config ⇒ Object
10 11 12 |
# File 'app/models/embeddable_model_config.rb', line 10 def self.ckeditor_config pluck :embeddable_tag_selector, :ckeditor_allowed_content end |
.embeddable_applet_models ⇒ Object
34 35 36 |
# File 'app/models/embeddable_model_config.rb', line 34 def self. where(embeddable_applet: true).map(&:embeddable_model) end |
.embeddable_image_models ⇒ Object
30 31 32 |
# File 'app/models/embeddable_model_config.rb', line 30 def self. where(embeddable_image: true).map(&:embeddable_model) end |
.embeddable_tree_based_models ⇒ Object
38 39 40 |
# File 'app/models/embeddable_model_config.rb', line 38 def self. where(tree_based: true).map(&:embeddable_model) end |
.for_model(embeddable_model) ⇒ Object
42 43 44 |
# File 'app/models/embeddable_model_config.rb', line 42 def self.for_model() find_by! embeddable_model_name: .model_name.name end |
Instance Method Details
#embeddable_model ⇒ Object
46 47 48 |
# File 'app/models/embeddable_model_config.rb', line 46 def .constantize end |
#styled_indicator_selector(tree_node: nil) ⇒ Object
50 51 52 53 54 |
# File 'app/models/embeddable_model_config.rb', line 50 def styled_indicator_selector(tree_node: nil) return unless tree_based? && tree_node.present? "#{}[data-tree-ref-id=\"#{tree_node.ref_id}\"]".html_safe end |