Module: BentoSearch::OpenurlAddOtherLink
- Defined in:
- app/item_decorators/bento_search/openurl_add_other_link.rb
Overview
DEPRECATED. Just write the logic into a custom Decorator yourself.
See wiki on decorators.
Example of an Item Decorator that ADDs an ‘other link’ with an openurl.
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::OpenurlAddOtherLink[:base_url => "http://resolve.somewhere.edu/foo", :extra_query => "&foo=bar"] ]
Class Method Summary collapse
Class Method Details
.[](options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/item_decorators/bento_search/openurl_add_other_link.rb', line 15 def self.[]() base_url = [:base_url] extra_query = [:extra_query] || "" link_name = [:link_name] || "Find It" # overwrite: if true, overwrite previously existing other_links, if # false add on to previously existing. overwrite = .has_key?(:overwrite) ? [:overwrite] : false Module.new do define_method :other_links do start = overwrite ? [] : super() if (ou = to_openurl) start + [BentoSearch::Link.new(:url => "#{base_url}?#{ou.kev}#{extra_query}", :label => link_name)] else start end end end end |