Module: Card::Content::All

Included in:
Card
Defined in:
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 'lib/card/content/all.rb', line 46

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

#clear_draftsObject



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

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

#contentObject



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

Returns:

  • (Boolean)


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

def content?
  content.present?
end

#content_objectObject



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

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

#last_draft_contentObject



42
43
44
# File '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 'lib/card/content/all.rb', line 50

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

#refresh_contentObject



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_contentObject



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_contentObject



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

def structured_content
  structure && default_content
end