Class: Atreides::Feature
- Includes:
- ActiveRecord::Validations, Base::AasmStates, Base::Taggable, Base::Validation, Extendable
- Defined in:
- app/models/atreides/feature.rb
Instance Attribute Summary collapse
-
#photo_url ⇒ Object
Constants.
Instance Method Summary collapse
- #photo ⇒ Object
- #set_tag_list ⇒ Object
-
#thumbnail(size = :thumb) ⇒ Object
Instance Methods.
- #video ⇒ Object
Methods included from Base::Validation
Methods included from Base::AasmStates
Methods included from Base::Taggable
Methods inherited from Base
Instance Attribute Details
#photo_url ⇒ Object
Constants
20 21 22 |
# File 'app/models/atreides/feature.rb', line 20 def photo_url @photo_url end |
Instance Method Details
#photo ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/models/atreides/feature.rb', line 71 def photo if post_id? part = post.parts.detect{|p|p.content_type && p.content_type.photos?} part ? part.photos.first : nil elsif photo_id? @photo ||= Atreides::Photo.find(photo_id) end end |
#set_tag_list ⇒ Object
43 44 45 |
# File 'app/models/atreides/feature.rb', line 43 def set_tag_list self.tag_list = [Settings..posts.features.first] if self.tag_list.empty? rescue [] end |
#thumbnail(size = :thumb) ⇒ Object
Instance Methods
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/atreides/feature.rb', line 57 def thumbnail(size = :thumb) # Find the first thumbnail image if post_id? post.thumbnail elsif photo_id? photo.image(size) else # FIXME: THIS NEEDS TO BE MOVED TO A VIEW/PRESENTER/DECORATOR # asset_path('atreides/missing_thumb.png') "/images/missing_thumb.png" end end |
#video ⇒ Object
80 81 82 83 84 85 |
# File 'app/models/atreides/feature.rb', line 80 def video if post_id? part = post.parts.detect{|p|p.content_type && p.content_type.videos?} part ? part.videos.first : nil end end |