Module: Collavre::Creative::Describable

Extended by:
ActiveSupport::Concern
Included in:
Collavre::Creative
Defined in:
app/models/collavre/creative/describable.rb

Instance Method Summary collapse

Instance Method Details

#creative_snippetObject



29
30
31
# File 'app/models/collavre/creative/describable.rb', line 29

def creative_snippet
  CGI.unescapeHTML(ActionController::Base.helpers.strip_tags(effective_origin.description || "")).truncate(24, omission: "...")
end

#effective_description(variation_id = nil, html = true) ⇒ Object

Linked Creative의 description을 안전하게 반환



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/collavre/creative/describable.rb', line 16

def effective_description(variation_id = nil, html = true)
  if variation_id.present?
    variation_tag = tags.find_by(label_id: variation_id)
    return variation_tag.value if variation_tag&.value.present?
  end
  description_val = origin_id.nil? ? description : origin.description
  if html
    description_val&.to_s || ""
  else
    ActionController::Base.helpers.strip_tags(description_val&.to_s || "")
  end
end