Module: Card::Content::All
- Included in:
- Card
- Defined in:
- lib/card/content/all.rb
Overview
content-related methods for cards
Instance Method Summary collapse
- #blank_content? ⇒ Boolean
- #clear_drafts ⇒ Object
- #content ⇒ Object
-
#content=(value) ⇒ Object
alias_method :raw_content, :content # DEPRECATED!.
- #content? ⇒ Boolean
- #content_object ⇒ Object
- #last_draft_content ⇒ Object
- #nests? ⇒ Boolean
- #refresh_content ⇒ Object
- #save_content_draft(_content) ⇒ Object
- #standard_content ⇒ Object
- #standardize_content(value) ⇒ Object
- #structured_content ⇒ Object
Instance Method Details
#blank_content? ⇒ Boolean
46 47 48 |
# File 'lib/card/content/all.rb', line 46 def blank_content? content.blank? || content.strip.blank? end |
#clear_drafts ⇒ Object
38 39 40 |
# File 'lib/card/content/all.rb', line 38 def clear_drafts drafts.created_by(Card::Auth.current_id).each(&:delete) end |
#content ⇒ Object
5 6 7 |
# File 'lib/card/content/all.rb', line 5 def content structured_content || standard_content end |
#content=(value) ⇒ Object
alias_method :raw_content, :content # DEPRECATED!
10 11 12 |
# File 'lib/card/content/all.rb', line 10 def content= value self.db_content = standardize_content value end |
#content? ⇒ Boolean
14 15 16 |
# File 'lib/card/content/all.rb', line 14 def content? content.present? end |
#content_object ⇒ Object
54 55 56 |
# File 'lib/card/content/all.rb', line 54 def content_object Card::Content.new content, self end |
#last_draft_content ⇒ Object
42 43 44 |
# File 'lib/card/content/all.rb', line 42 def last_draft_content drafts.last.card_changes.last.value end |
#nests? ⇒ Boolean
50 51 52 |
# File 'lib/card/content/all.rb', line 50 def nests? content_object.has_chunk? Content::Chunk::Nest end |
#refresh_content ⇒ Object
30 31 32 |
# File 'lib/card/content/all.rb', line 30 def refresh_content self.content = Card.find(id)&.db_content end |
#save_content_draft(_content) ⇒ Object
34 35 36 |
# File 'lib/card/content/all.rb', line 34 def save_content_draft _content clear_drafts end |
#standard_content ⇒ Object
18 19 20 |
# File 'lib/card/content/all.rb', line 18 def standard_content db_content || (new_card? ? default_content : "") end |
#standardize_content(value) ⇒ Object
22 23 24 |
# File 'lib/card/content/all.rb', line 22 def standardize_content value value.is_a?(Array) ? items_content(value) : value end |
#structured_content ⇒ Object
26 27 28 |
# File 'lib/card/content/all.rb', line 26 def structured_content structure && default_content end |