Module: Card::Set::All::Content

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-card/mod001-core/all/content.rb,
platypus/tmp/set/gem-defaults/mod004-format/all/content.rb

Overview

Set: All cards (Content)

Defined Under Namespace

Modules: Format, HtmlFormat

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from Card::Set::AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/content.rb"; end

Instance Method Details

#blank_comment?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 45

def blank_comment?
  comment.blank? || comment.strip.blank?
end

#clean_html?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 28

def clean_html?
  true
end

#creatorObject



72
73
74
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 72

def creator
  Card[creator_id]
end

#default_contentObject

TODO: let default_content in card_accessor override template



33
34
35
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 33

def default_content
  template&.db_content
end

#draft?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 24

def draft?
  Env.params["draft"] == "true"
end

#event: save_draftObject



14
15
16
17
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 14

event :save_draft, :store, on: :update, when: :draft? do
  save_content_draft content
  abort :success
end

#event: set_contentObject



8
9
10
11
12
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 8

event :set_content, :store, on: :save do
  self.content = prepare_db_content
  @selected_action_id = @selected_content = nil
  clear_drafts
end

#event: set_default_contentObject



19
20
21
22
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 19

event :set_default_content, :prepare_to_validate,
      on: :create, when: :use_default_content? do
  self.db_content = default_content
end

#labelObject

seems like this should be moved to format so we can fall back on title rather than name. (In fact, name, title, AND label is a bit much. Trim to 2?)



68
69
70
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 68

def label
  name
end

#prepare_db_contentObject



49
50
51
52
53
54
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 49

def prepare_db_content
  cont = standard_db_content || "" # necessary?

  # TODO: move this html-specific code somewhere more appropriate
  clean_html? ? Card::Content.clean!(cont) : cont
end

#standard_db_contentObject



56
57
58
59
60
61
62
63
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 56

def standard_db_content
  if structure
    # do not override db_content with content from structure
    db_content
  else
    standard_content
  end
end

#unfilled?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 41

def unfilled?
  blank_content? && blank_comment? && !subcards?
end

#updaterObject



76
77
78
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 76

def updater
  Card[updater_id]
end

#use_default_content?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'platypus/tmp/set/gem-card/mod001-core/all/content.rb', line 37

def use_default_content?
  !db_content_changed? && default_content.present?
end