# File rss/dublincore.rb, line 11
def append_features(klass)
super
return if klass.instance_of?(Module)
DublinCoreModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
plural = plural_name || "#{name}s"
full_name = "#{DC_PREFIX}_#{name}"
full_plural_name = "#{DC_PREFIX}_#{plural}"
klass_name = "DublinCore#{Utils.to_class_name(name)}"
klass.install_must_call_validator(DC_PREFIX, DC_URI)
klass.install_have_children_element(name, DC_URI, "*",
full_name, full_plural_name)
klass.module_eval(" remove_method :#{full_name}
remove_method :#{full_name}=
remove_method :set_#{full_name}
def #{full_name}
@#{full_name}.first and @#{full_name}.first.value
end
def #{full_name}=(new_value)
@#{full_name}[0] = Utils.new_with_value_if_need(#{klass_name}, new_value)
end
alias set_#{full_name} #{full_name}=
", *get_file_and_line_from_caller(0))
end
klass.module_eval(" alias date #{DC_PREFIX}_date
alias date= #{DC_PREFIX}_date=
", *get_file_and_line_from_caller(0))
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.