Commit df3a8d9a by ivan Lan

Add media_klass to filter class by media_type

parent b6cc9e37
...@@ -36,7 +36,17 @@ module Whaleback ...@@ -36,7 +36,17 @@ module Whaleback
'video' => 'Media::Video', 'video' => 'Media::Video',
'voice' => 'Media::Voice', 'voice' => 'Media::Voice',
} }
class << self
def media_klass media_type
Media::Obj::TypeTrans[ media_type.to_s ].to_s.safe_constantize || raise_wrong_media_type(media_type)
end
def raise_wrong_media_type
raise Whaleback::Errors::BaseError.new("Invalid media_type: #{media_type}", -1, 400)
end
end
attr_accessor :default_mode attr_accessor :default_mode
def url mode=nil def url mode=nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment