Sha256: b575a26dc8f44308c9ad90286dff8a1da80bddac19eebcb341d32a5bae46286f

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

module BentoSearch
  # Represents an 'additional link' held in BentoSearch::ResultItem#other_links
  #
  # label, url, other metadata about the link. 
  class Link
    # url is normally a string, but can also be a Hash passed
    # to url_for in the local app. 
    attr_accessor :label, :url
    
    # Used both for HTML links and possibly later Atom. 
    # Must be a string, EITHER a complete URL (representing
    # vocab term), OR a legal short name from 
    # http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#linkTypes    
    attr_accessor :rel
    
    # MIME content type may be used for both HMTL links and Atom
    # link 'type' attribute
    attr_accessor :type
    
    # Array of strings, used for CSS classes on this link, possibly
    # for custom styles/images etc. May be used in non-html link
    # contexts too. 
    attr_accessor :style_classes
    
    # Suggested `target` attribute to render link with as html <a> 
    attr_accessor :target
    
    def initialize(hash = {})
      self.style_classes = []
      
      hash.each_pair do |key, value|
        send("#{key}=", value)
      end            
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bento_search-1.3.0 app/models/bento_search/link.rb
bento_search-1.2.2 app/models/bento_search/link.rb
bento_search-1.2.1 app/models/bento_search/link.rb
bento_search-1.2.0 app/models/bento_search/link.rb
bento_search-1.1.0 app/models/bento_search/link.rb
bento_search-1.0.6 app/models/bento_search/link.rb
bento_search-1.0.4 app/models/bento_search/link.rb
bento_search-1.0.3 app/models/bento_search/link.rb
bento_search-1.0.2 app/models/bento_search/link.rb
bento_search-1.0.1 app/models/bento_search/link.rb
bento_search-1.0.0 app/models/bento_search/link.rb