Class: Atreides::Feature

Inherits:
Base
  • Object
show all
Includes:
ActiveRecord::Validations, Base::AasmStates, Base::Taggable, Base::Validation, Extendable
Defined in:
app/models/atreides/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base::Validation

included

Methods included from Base::AasmStates

included

Methods included from Base::Taggable

included

Methods inherited from Base

#dom_id, #to_param

Instance Attribute Details

#photo_urlObject

Constants



20
21
22
# File 'app/models/atreides/feature.rb', line 20

def photo_url
  @photo_url
end

Instance Method Details

#photoObject



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_listObject



43
44
45
# File 'app/models/atreides/feature.rb', line 43

def set_tag_list
  self.tag_list = [Settings.tags.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

#videoObject



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