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
113
def to_rss(rss, current)
114
@taxo_topics.each do |taxo_topic|
115
taxo_topic.to_rss(rss, current)
119
class TaxonomyTopicBase
121
include DublinCoreModel
122
include TaxonomyTopicsModel
125
add_need_initialize_variable("value")
126
alias_method(:taxo_link, :value)
127
alias_method(:taxo_link=, :value=)
129
def have_required_values?
137
include TaxonomyTopicModel
141
include TaxonomyTopicsModel
146
include TaxonomyTopicsModel
151
TaxonomyTopicModel.install_taxo_topic(self)
154
TaxonomyTopicsModel.install_taxo_topics(self)
159
TaxonomyTopicsModel.install_taxo_topics(self)
165
TaxonomyTopicModel.install_taxo_topic(self)
168
TaxonomyTopicsModel.install_taxo_topics(self)
173
TaxonomyTopicsModel.install_taxo_topics(self)