2
require 'rss/maker/1.0'
3
require 'rss/maker/dublincore'
7
module TaxonomyTopicsModel
8
def self.append_features(klass)
11
klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
12
klass.add_other_element("taxo_topics")
13
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
14
attr_reader :taxo_topics
16
self.class::TaxonomyTopics.new(@maker)
19
def setup_taxo_topics(rss, current)
20
@taxo_topics.to_rss(rss, current)
25
def self.install_taxo_topics(klass)
26
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
27
class TaxonomyTopics < TaxonomyTopicsBase
28
def to_rss(rss, current)
29
if current.respond_to?(:taxo_topics)
30
topics = current.class::TaxonomyTopics.new
32
@resources.each do |resource|
33
bag.lis << RDF::Bag::Li.new(resource)
35
current.taxo_topics = topics
42
class TaxonomyTopicsBase
45
attr_reader :resources
46
def_array_element("resources")
50
module TaxonomyTopicModel
51
def self.append_features(klass)
54
klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
55
klass.add_other_element("taxo_topics")
56
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
57
attr_reader :taxo_topics
59
self.class::TaxonomyTopics.new(@maker)
62
def setup_taxo_topics(rss, current)
63
@taxo_topics.to_rss(rss, current)
67
@taxo_topics[0] and @taxo_topics[0].value
70
def taxo_topic=(new_value)
71
@taxo_topic[0] = self.class::TaxonomyTopic.new(self)
72
@taxo_topic[0].value = new_value
77
def self.install_taxo_topic(klass)
78
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
79
class TaxonomyTopics < TaxonomyTopicsBase
80
class TaxonomyTopic < TaxonomyTopicBase
81
DublinCoreModel.install_dublin_core(self)
82
TaxonomyTopicsModel.install_taxo_topics(self)
84
def to_rss(rss, current)
85
if current.respond_to?(:taxo_topics)
86
topic = current.class::TaxonomyTopic.new(value)
87
topic.taxo_link = value
88
taxo_topics.to_rss(rss, topic) if taxo_topics
89
current.taxo_topics << topic
90
setup_other_elements(rss)
94
def current_element(rss)
95
super.taxo_topics.last
102
class TaxonomyTopicsBase
105
def_array_element("taxo_topics")
108
taxo_topic = self.class::TaxonomyTopic.new(self)
109
@taxo_topics << taxo_topic
117
def to_rss(rss, current)
118
@taxo_topics.each do |taxo_topic|
119
taxo_topic.to_rss(rss, current)
123
class TaxonomyTopicBase
125
include DublinCoreModel
126
include TaxonomyTopicsModel
129
add_need_initialize_variable("value")
130
alias_method(:taxo_link, :value)
131
alias_method(:taxo_link=, :value=)
133
def have_required_values?
141
include TaxonomyTopicModel
145
include TaxonomyTopicsModel
150
include TaxonomyTopicsModel
155
TaxonomyTopicModel.install_taxo_topic(self)
158
TaxonomyTopicsModel.install_taxo_topics(self)
163
TaxonomyTopicsModel.install_taxo_topics(self)
169
TaxonomyTopicModel.install_taxo_topic(self)
172
TaxonomyTopicsModel.install_taxo_topics(self)
177
TaxonomyTopicsModel.install_taxo_topics(self)