Sha256: 8f8f102b8095cc1d9bd0e68c5d31924332b895db9bf29851c61c0a666e85dafe

Contents?: true

Size: 807 Bytes

Versions: 21

Compression:

Stored size: 807 Bytes

Contents

require 'digest/md5'

class Media < ActiveRecord::Base

    # Create a hash based on publication time and title that should uniquely identify 
    # this publication of the document.
    before_save :before_save_method
     
    def before_save_method
        if (self["title"].nil?)
            raise "This is an issue.... there's no title"
            Rails.logger.warn("Found video with no title")
            return false
        end
        str = (self["published_at"].nil?) ? self["title"] : (self["title"] + self["published_at"].to_s)
        self["digest"] = Digest::SHA1.hexdigest(str)
    end
    
    def is_video? 
        true
    end

    def is_twitter?
        false
    end
    
    def is_article?
        false
    end
    
    def thumbnail_url
        self.thumb_image_url
    end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sports_db-0.2.6 app/models/media.rb
sports_db-0.2.5 app/models/media.rb
sports_db-0.2.4 app/models/media.rb
sports_db-0.2.3 app/models/media.rb
sports_db-0.2.2 app/models/media.rb
sports_db-0.2.1 app/models/media.rb
sports_db-0.2 app/models/media.rb
sports_db-0.0.13 app/models/media.rb
sports_db-0.1.3 app/models/media.rb
sports_db-0.1.2 app/models/media.rb
sports_db-0.1.1 app/models/media.rb
sports_db-0.1.0 app/models/media.rb
sports_db-0.0.9 app/models/media.rb
sports_db-0.0.8 app/models/media.rb
sports_db-0.0.7 app/models/media.rb
sports_db-0.0.6 app/models/media.rb
sports_db-0.0.5 app/models/media.rb
sports_db-0.0.4 app/models/media.rb
sports_db-0.0.3 app/models/media.rb
sports_db-0.0.2 app/models/media.rb