Class: Effective::Snippets::Snippet
- Inherits:
-
Object
- Object
- Effective::Snippets::Snippet
- Defined in:
- app/models/effective/snippets/snippet.rb
Direct Known Subclasses
Instance Method Summary collapse
- #class_name ⇒ Object
- #data ⇒ Object
- #id ⇒ Object
-
#initialize(atts = {}) ⇒ Snippet
constructor
A new instance of Snippet.
- #snippet_description ⇒ Object
- #snippet_dialog_url ⇒ Object
- #snippet_editables ⇒ Object
- #snippet_inline ⇒ Object
-
#snippet_label ⇒ Object
The following methods are used for the CKEditor widget creation.
-
#snippet_tag ⇒ Object
This is the tag that the ckeditor snippet will be created as It supports divs and spans, but that’s it No ULs, or LIs.
- #to_partial_path ⇒ Object
Constructor Details
#initialize(atts = {}) ⇒ Snippet
Returns a new instance of Snippet.
19 20 21 |
# File 'app/models/effective/snippets/snippet.rb', line 19 def initialize(atts = {}) (atts || {}).each { |k, v| self.send("#{k}=", v) if respond_to?("#{k}=") } end |
Instance Method Details
#class_name ⇒ Object
35 36 37 |
# File 'app/models/effective/snippets/snippet.rb', line 35 def class_name @class_name ||= self.class.name.demodulize.underscore.to_sym end |
#data ⇒ Object
27 28 29 |
# File 'app/models/effective/snippets/snippet.rb', line 27 def data self.attributes.reject { |k, v| [:region, :id].include?(k) } end |
#id ⇒ Object
23 24 25 |
# File 'app/models/effective/snippets/snippet.rb', line 23 def id super.presence || "snippet_#{object_id}" end |
#snippet_description ⇒ Object
44 45 46 |
# File 'app/models/effective/snippets/snippet.rb', line 44 def snippet_description "Insert #{snippet_label}" end |
#snippet_dialog_url ⇒ Object
48 49 50 |
# File 'app/models/effective/snippets/snippet.rb', line 48 def snippet_dialog_url "/assets/effective/snippets/#{class_name}.js" end |
#snippet_editables ⇒ Object
63 64 65 |
# File 'app/models/effective/snippets/snippet.rb', line 63 def snippet_editables false end |
#snippet_inline ⇒ Object
59 60 61 |
# File 'app/models/effective/snippets/snippet.rb', line 59 def snippet_inline [:span].include?(snippet_tag) end |
#snippet_label ⇒ Object
The following methods are used for the CKEditor widget creation.
40 41 42 |
# File 'app/models/effective/snippets/snippet.rb', line 40 def snippet_label class_name.to_s.humanize end |
#snippet_tag ⇒ Object
This is the tag that the ckeditor snippet will be created as It supports divs and spans, but that’s it No ULs, or LIs
55 56 57 |
# File 'app/models/effective/snippets/snippet.rb', line 55 def snippet_tag :div end |
#to_partial_path ⇒ Object
31 32 33 |
# File 'app/models/effective/snippets/snippet.rb', line 31 def to_partial_path "effective/snippets/#{class_name}" end |