Module: RSS::Maker::TaxonomyTopicsModel

Defined Under Namespace

Classes: TaxonomyTopicsBase

Class Method Summary collapse

Class Method Details

.append_features(klass) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rss/maker/taxonomy.rb', line 8

def self.append_features(klass)
  super

  klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
  klass.add_other_element("taxo_topics")
  klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
    attr_reader :taxo_topics
    def make_taxo_topics
      self.class::TaxonomyTopics.new(@maker)
    end
      
    def setup_taxo_topics(rss, current)
      @taxo_topics.to_rss(rss, current)
    end
EOC
end

.install_taxo_topics(klass) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rss/maker/taxonomy.rb', line 25

def self.install_taxo_topics(klass)
  klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
    class TaxonomyTopics < TaxonomyTopicsBase
      def to_rss(rss, current)
        if current.respond_to?(:taxo_topics)
          topics = current.class::TaxonomyTopics.new
          bag = topics.Bag
          @resources.each do |resource|
            bag.lis << RDF::Bag::Li.new(resource)
          end
          current.taxo_topics = topics
        end
      end
    end
EOC
end