Move the unserialized_attribute override into the youtube_titles module.
This commit is contained in:
parent
a4e54a7b05
commit
015879a96a
2 changed files with 11 additions and 12 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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(?:\?|#!|.+&|.+&)v=)([\w-]{11})(?:\S*(#[^ ]+)|\S+)?/im unless defined? YOUTUBE_ID_REGEX
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue