Module: RSS::Maker::DublinCoreModel
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
Atom::Entry::Channel,
Atom::Entry::Image,
Atom::Entry::Textinput,
Atom::Feed::Channel,
Atom::Feed::Image,
Atom::Feed::Textinput,
ChannelBase,
ImageBase,
ImageFaviconModel::ImageFaviconBase,
ImageItemModel::ImageItemBase,
ItemsBase::ItemBase,
RSS091::Channel,
RSS091::Image,
RSS091::Textinput,
RSS092::Channel,
RSS092::Image,
RSS092::Textinput,
RSS09::Channel,
RSS09::Image,
RSS09::Textinput,
RSS10::Channel,
RSS10::Image,
RSS10::Textinput,
RSS20::Channel,
RSS20::Image,
RSS20::Textinput,
TextinputBase
| |
Defined in: | lib/rss/maker/dublincore.rb |
Class Method Summary
Class Method Details
.append_features(klass)
[ GitHub ]# 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}" plural_klass_name = "DublinCore#{Utils.to_class_name(plural_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
.install_dublin_core(klass)
[ GitHub ]# File 'lib/rss/maker/dublincore.rb', line 70
def self.install_dublin_core(klass) ::RSS::DublinCoreModel::ELEMENT_NAME_INFOS.each do |name, plural_name| plural_name ||= "#{name}s" klass_name = Utils.to_class_name(name) full_klass_name = "DublinCore#{klass_name}" plural_klass_name = "DublinCore#{Utils.to_class_name(plural_name)}" klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1) class #{plural_klass_name} < #{plural_klass_name}Base class #{full_klass_name} < #{full_klass_name}Base end #{klass_name} = #{full_klass_name} end EOC end end