Sha256: be01bdcaec4281c42556d135c47a843e22725c974a8d9b1a442472f2dc787867

Contents?: true

Size: 906 Bytes

Versions: 7

Compression:

Stored size: 906 Bytes

Contents

module GovKit::ActsAsCiteable

  def self.included(base)
    base.extend ActMethods
  end

  module ActMethods
    def acts_as_citeable(options={})
      options[:keywords] ||= []

      class_inheritable_accessor :options
      self.options = options

      unless included_modules.include? InstanceMethods
        extend ClassMethods
        include InstanceMethods
      end
    end
  end

  module ClassMethods
  end

  module InstanceMethods

    def raw_citations
      params = self.options[:keywords].clone
      attributes = self.options[:with].clone

      attributes.each do |attr|
        params << self.instance_eval("#{attr}")
      end
      {
        :google_news => GovKit::SearchEngines::GoogleNews.search(params),
        :google_blogs => GovKit::SearchEngines::GoogleBlog.search(params),
        :technorati => GovKit::SearchEngines::Technorati.search(params)
      }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
govkit-0.4.2 lib/gov_kit/acts_as_citeable.rb
govkit-0.4.1 lib/gov_kit/acts_as_citeable.rb
govkit-0.4.0 lib/gov_kit/acts_as_citeable.rb
govkit-0.3.2 lib/gov_kit/acts_as_citeable.rb
govkit-0.3.1 lib/gov_kit/acts_as_citeable.rb
govkit-0.3.0 lib/gov_kit/acts_as_citeable.rb
govkit-0.2.0 lib/gov_kit/acts_as_citeable.rb