12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/videoclip.rb', line 12
def has_video(*names)
options = names..symbolize_keys
names.collect!(&:to_sym)
names << :video if names.empty?
class_inheritable_hash :videoclip_options
self.videoclip_options ||= {}
names.each do |name|
self.videoclip_options.update(name => 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
end
|