Class: Testimonials::Testimonial
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Testimonials::Testimonial
- Defined in:
- app/models/testimonials/testimonial.rb
Overview
One testimonial — text or video. Author attribution is optional and stored as loose fields (no foreign key to the host's user table) so the model is portable across apps with different user models.
Constant Summary collapse
- KINDS =
%w[text video].freeze
- STATUSES =
%w[pending approved archived].freeze
- SOURCES =
%w[widget page nps].freeze
Instance Method Summary collapse
- #avatar_attached? ⇒ Boolean
- #display_name ⇒ Object
- #poster_attached? ⇒ Boolean
-
#quote ⇒ Object
The curated pull-quote when the admin picked one, else the full text.
- #video? ⇒ Boolean
- #video_attached? ⇒ Boolean
Instance Method Details
#avatar_attached? ⇒ Boolean
45 46 47 |
# File 'app/models/testimonials/testimonial.rb', line 45 def avatar_attached? respond_to?(:avatar) && avatar.attached? end |
#display_name ⇒ Object
49 50 51 |
# File 'app/models/testimonials/testimonial.rb', line 49 def display_name name.presence || (.present? ? "##{}" : nil) end |
#poster_attached? ⇒ Boolean
41 42 43 |
# File 'app/models/testimonials/testimonial.rb', line 41 def poster_attached? respond_to?(:poster) && poster.attached? end |
#quote ⇒ Object
The curated pull-quote when the admin picked one, else the full text.
54 55 56 |
# File 'app/models/testimonials/testimonial.rb', line 54 def quote best_line.presence || body end |
#video? ⇒ Boolean
35 |
# File 'app/models/testimonials/testimonial.rb', line 35 def video? = kind == 'video' |
#video_attached? ⇒ Boolean
37 38 39 |
# File 'app/models/testimonials/testimonial.rb', line 37 def video_attached? respond_to?(:video_file) && video_file.attached? end |