Module: Utils

Extended by:
ActiveSupport::Concern
Included in:
Challenge, Comment, Document, Need, Post, Program, Project, Space, User, Workgroup
Defined in:
app/models/concerns/utils.rb

Instance Method Summary collapse

Instance Method Details

#obj_typeObject



6
7
8
# File 'app/models/concerns/utils.rb', line 6

def obj_type
  self.class.name
end

#reindex(_anything) ⇒ Object



28
29
30
# File 'app/models/concerns/utils.rb', line 28

def reindex(_anything)
  index! if persisted?
end

#sanitize(text) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/models/concerns/utils.rb', line 10

def sanitize(text)
  ActionController::Base.helpers.sanitize(
    text,
    options = {
      tags: %w[p br h1 h2 h3 a strong em u s sub sup span img iframe pre blockquote ul li ol],
      attributes: %w[height width style src href rel target class allowfullscreen frameborder data-value data-index data-denotation-char data-link]
    }
  )
end

#sanitize_contentObject



24
25
26
# File 'app/models/concerns/utils.rb', line 24

def sanitize_content
  self.content = sanitize(content)
end

#sanitize_descriptionObject



20
21
22
# File 'app/models/concerns/utils.rb', line 20

def sanitize_description
  self.description = sanitize(description)
end