Module: LoyalCore::ActsAsContentModeAble::ClassMethods::ContentModeInstanceMethods

Extended by:
Memoist
Defined in:
lib/loyal_core/acts/content_mode_able.rb

Instance Method Summary collapse

Methods included from Memoist

escape_punctuation, extract_reload!, memoist_eval, memoize, memoized_ivar_for, memoized_prefix, unmemoized_method_for, unmemoized_prefix

Instance Method Details

#contentObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/loyal_core/acts/content_mode_able.rb', line 60

def content
  case self.content_mode_name
  when :html
    ::LoyalCore::TextUtil.syntax_highlighter(
      ::Sanitize.clean(self.content_code, ::LoyalCore.config.sanitize_config[:relaxed])
    )
  when :markdown
    # TODO: markdown
    ::LoyalCore::TextUtil.markdown(self.content_code)
  when :text
    self.content_text
  end
end

#content=(content) ⇒ Object



74
75
76
# File 'lib/loyal_core/acts/content_mode_able.rb', line 74

def content= content
  self.content_code = content
end

#content_mode_nameObject



56
57
58
# File 'lib/loyal_core/acts/content_mode_able.rb', line 56

def content_mode_name
  self.class.content_mode_config.item(self.content_mode).key
end

#content_mode_name=(name) ⇒ Object



52
53
54
# File 'lib/loyal_core/acts/content_mode_able.rb', line 52

def content_mode_name= name
  self.content_mode = self.class.content_mode_config.at(name).value
end

#content_mode_was_cacheObject

FIXME



38
39
40
41
42
# File 'lib/loyal_core/acts/content_mode_able.rb', line 38

def content_mode_was_cache
  (
    @content_mode_was_cache ||= self.content_mode
  ).to_i
end

#content_mode_was_cache=(mode) ⇒ Object



44
45
46
# File 'lib/loyal_core/acts/content_mode_able.rb', line 44

def content_mode_was_cache= mode
  @content_mode_was_cache = mode
end

#content_mode_was_cache_changed?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/loyal_core/acts/content_mode_able.rb', line 48

def content_mode_was_cache_changed?
  self.content_mode_was_cache != self.content_mode
end

#content_mode_was_cache_reset!Object



33
34
35
# File 'lib/loyal_core/acts/content_mode_able.rb', line 33

def content_mode_was_cache_reset!
  @content_mode_was_cache = self.content_mode
end

#content_textObject



78
79
80
# File 'lib/loyal_core/acts/content_mode_able.rb', line 78

def content_text
  ::Sanitize.clean(self.content_code, ::LoyalCore.config.sanitize_config[:text])  || 0
end