7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rss/maker/dublincore.rb', line 7
def self.append_features(klass)
super
::RSS::DublinCoreModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
plural_name ||= "#{name}s"
full_name = "#{RSS::DC_PREFIX}_#{name}"
full_plural_name = "#{RSS::DC_PREFIX}_#{plural_name}"
klass_name = Utils.to_class_name(name)
plural_klass_name = "DublinCore#{Utils.to_class_name(plural_name)}"
full_plural_klass_name = "self.class::#{plural_klass_name}"
full_klass_name = "#{full_plural_klass_name}::#{klass_name}"
klass.def_classed_elements(full_name, "value", plural_klass_name,
full_plural_name, name)
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
def new_#{full_name}(value=nil)
_#{full_name} = #{full_plural_name}.new_#{name}
_#{full_name}.value = value
if block_given?
yield _#{full_name}
else
_#{full_name}
end
end
EOC
end
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
# For backward compatibility
alias #{DC_PREFIX}_rightses #{DC_PREFIX}_rights_list
EOC
end
|