Class: Omnom::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Omnom::Post
- Defined in:
- app/models/omnom/post.rb
Instance Method Summary collapse
Instance Method Details
#clean_urls ⇒ Object
20 21 22 23 24 25 |
# File 'app/models/omnom/post.rb', line 20 def clean_urls [:author_url, :comments_url, :thumbnail_url, :url].each do |attribute| value = send(attribute) send("#{attribute}=", Omnom::Utils.clean_url(value)) if value.present? end end |
#set_thumbnail_size ⇒ Object
27 28 29 30 31 32 |
# File 'app/models/omnom/post.rb', line 27 def set_thumbnail_size return if thumbnail_url.blank? size = FastImage.size(thumbnail_url) return if size.blank? self.thumbnail_width, self.thumbnail_height = size end |
#source ⇒ Object
43 44 45 |
# File 'app/models/omnom/post.rb', line 43 def source posts_origins.first.source end |
#truncate_fields ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/models/omnom/post.rb', line 34 def truncate_fields fields = [:title, :subtitle] fields.each do |field| value = send(field) next if value.nil? send("#{field}=", value.truncate(255)) end end |