Module: EmbeddedURL::ClassMethods

Defined in:
lib/embedded_url.rb

Instance Method Summary collapse

Instance Method Details

#with_embedded(field) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/embedded_url.rb', line 16

def with_embedded(field)
  
  define_method("embedded_#{field}") do

    link = send(field)
    
    begin
      Gist.new(link).to_embedded || 
        Youtube.new(link).to_embedded || 
        Vimeo.new(link).to_embedded || 
        SlideShare.new(link).to_embedded ||
        (link =~ /^http/ ? link : "http://#{link}")
    rescue
    end
    
  end
  
end