Module: BentoSearch::Ebscohost::ConditionalOpenurlMainLink

Defined in:
app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb

Overview

DEPRECATED. Just write the logic into a custom Decorator yourself.

See wiki on decorators.

For ebscohost connector, example of an Item Decorator that replaces the main ‘link’ with an openurl ONLY if there is NOT fulltext avail from EBSCO.

This example uses crazy metaprogramming to dynamically create a module configured with your base url etc. You don’t need to use crazy method like that; just define your own local decorator doing exactly what you need, it’s meant to be simple.

config.item_decorators = [ BentoSearch::Ebscohost::ConditionalOpenurlMainLink[:base_url => "http://resolve.somewhere.edu/foo", :extra_query => "&foo=bar"] ]

Class Method Summary collapse

Class Method Details

.[](options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb', line 16

def self.[](options)
  base_url = options[:base_url]
  extra_query = options[:extra_query] || ""
  Module.new do
    
    define_method :link do
      if custom_data["fulltext_formats"]
        super()
      elsif (ou = to_openurl)
        "#{base_url}?#{ou.kev}#{extra_query}"
      else
        nil
      end
    end
    
  end
end