Module: LaserLemon::Videoclip::ClassMethods

Defined in:
lib/videoclip.rb

Instance Method Summary collapse

Instance Method Details

#has_video(name = :video, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/videoclip.rb', line 12

def has_video(name = :video, options = {})
  class_inheritable_hash :videoclip_options
  self.videoclip_options = {name.to_sym => options}

  composed_of name,
    :class_name => 'LaserLemon::Videoclip::Video',
    :mapping => %w(host key url).map{|x| %W(#{name}_#{x} #{x}) },
    :constructor => Proc.new{|h,k,u| LaserLemon::Videoclip::Video.build(h, k, u, options) },
    :converter => Proc.new{|u| LaserLemon::Videoclip::Video.assign(u, options) },
    :allow_nil => true

  define_method "#{name}?" do
    !! send(name)
  end
end