Move the unserialized_attribute override into the youtube_titles module.

This commit is contained in:
Raphael Sofaer 2011-08-09 14:23:50 -07:00
parent a4e54a7b05
commit 015879a96a
2 changed files with 11 additions and 12 deletions

View file

@ -131,18 +131,6 @@ class StatusMessage < Post
end
end
def unserialize_attribute attr_name
if attr_name == "youtube_titles"
begin
super
rescue ActiveRecord::SerializationTypeMismatch
{}
end
else
super
end
end
protected
def message_or_photos_present?

View file

@ -31,5 +31,16 @@ module YoutubeTitles
self.youtube_titles = matches unless matches.empty?
end
def unserialize_attribute attr_name
if attr_name == "youtube_titles"
begin
super
rescue ActiveRecord::SerializationTypeMismatch
{}
end
else
super
end
end
YOUTUBE_ID_REGEX = /(?:https?:\/\/)(?:youtu\.be\/|(?:[a-z]{2,3}\.)?youtube\.com\/watch(?:\?|#!|.+&|.+&amp;)v=)([\w-]{11})(?:\S*(#[^ ]+)|\S+)?/im unless defined? YOUTUBE_ID_REGEX
end