Module: Card::Content::All

Included in:
Card
Defined in:
card/lib/card/content/all.rb

Overview

content-related methods for cards

Instance Method Summary collapse

Instance Method Details

#blank_content?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'card/lib/card/content/all.rb', line 46

def blank_content?
  content.blank? || content.strip.blank?
end

#clear_draftsObject



38
39
40
# File 'card/lib/card/content/all.rb', line 38

def clear_drafts
  drafts.created_by(Card::Auth.current_id).each(&:delete)
end

#contentObject Also known as: raw_content



5
6
7
# File 'card/lib/card/content/all.rb', line 5

def content
  structured_content || standard_content
end

#content=(value) ⇒ Object



10
11
12
# File 'card/lib/card/content/all.rb', line 10

def content= value
  self.db_content = standardize_content(value)
end

#content?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'card/lib/card/content/all.rb', line 14

def content?
  content.present?
end

#content_objectObject



54
55
56
# File 'card/lib/card/content/all.rb', line 54

def content_object
  Card::Content.new content, self
end

#last_draft_contentObject



42
43
44
# File 'card/lib/card/content/all.rb', line 42

def last_draft_content
  drafts.last.card_changes.last.value
end

#nests?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'card/lib/card/content/all.rb', line 50

def nests?
  content_object.has_chunk? Content::Chunk::Nest
end

#refresh_contentObject



30
31
32
# File 'card/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 'card/lib/card/content/all.rb', line 34

def save_content_draft _content
  clear_drafts
end

#standard_contentObject



18
19
20
# File 'card/lib/card/content/all.rb', line 18

def standard_content
  db_content || (new_card? && template.db_content)
end

#standardize_content(value) ⇒ Object



22
23
24
# File 'card/lib/card/content/all.rb', line 22

def standardize_content value
  value.is_a?(Array) ? value.join("\n") : value
end

#structured_contentObject



26
27
28
# File 'card/lib/card/content/all.rb', line 26

def structured_content
  structure && template.db_content
end