Module: Card::Set::All::Comment

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb

Overview

Set: All cards (Comment)

Defined Under Namespace

Modules: Format

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Instance Attribute Summary collapse

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

Instance Attribute Details

#comment_authorObject



23
24
25
26
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 23

def comment_author
  @comment_author ||=
    Env.session[:comment_author] || Env.params[:comment_author] || "Anonymous"
end

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 7

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

Instance Method Details

#clean_commentObject



28
29
30
31
32
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 28

def clean_comment
  comment.split(/\n/).map do |line|
    "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"
  end * "\n"
end

#commenting?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 8

def commenting?
  comment && action != :delete
end

#event: add_commentObject



12
13
14
15
16
17
18
19
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 12

event :add_comment, :prepare_to_store, on: :save, when: :comment do
  Env.session[:comment_author] = comment_author if Env.session
  return unless comment.present?

  self.content =
    [content, format.comment_with_signature].compact.join "\n<hr\>\n"
  self.comment = nil
end