Module: GovKit::ActsAsNoteworthy::ActMethods

Defined in:
lib/gov_kit/acts_as_noteworthy.rb

Overview

Module to make a rails model act as a noteworthy object, linking it to govkit’s mention model

Instance Method Summary collapse

Instance Method Details

#acts_as_noteworthy(options = {}) ⇒ Object

Sets up the relationship between the model and the mention model



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gov_kit/acts_as_noteworthy.rb', line 12

def acts_as_noteworthy(options={})
  class_inheritable_accessor :options
  self.options = options

  unless included_modules.include? InstanceMethods
    instance_eval do
      has_many :mentions, :as => :owner, :order => 'date desc'

      with_options :as => :owner, :class_name => "Mention" do |c|
        c.has_many :google_news_mentions, :conditions => {:search_source => "Google News"}, :order => 'date desc'
        c.has_many :google_blog_mentions, :conditions => {:search_source => "Google Blogs"}, :order => 'date desc'
#            c.has_many :technorati_mentions, :conditions => {:search_source => "Technorati"}, :order => 'date desc'
        c.has_many :bing_mentions, :conditions => {:search_source => "Bing"}, :order => 'date desc'
      end
    end

    extend ClassMethods
    include InstanceMethods
  end
end