Sha256: e76a67b5954693768fcf858fb09026c3baa603095420a15f65514c57cbf4baba

Contents?: true

Size: 535 Bytes

Versions: 5

Compression:

Stored size: 535 Bytes

Contents

module It
  # A class for links
  class Link < Tag
    include ActionView::Helpers::UrlHelper
    
    # See It.link for details. You can do everything there and save 6 characters.
    def initialize(href, options = {})
      raise TypeError, "Invalid href given" unless href.is_a?(Hash) || href.is_a?(String)
      super(:a, options)
      @href = href
    end
    
    # Will be called from inside the helper to return the tag with the given content.
    def process(content)
      link_to(content, @href, @options)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
it-0.2.5 lib/it/link.rb
it-0.2.4 lib/it/link.rb
it-0.2.3 lib/it/link.rb
it-0.2.1 lib/it/link.rb
it-0.2.0 lib/it/link.rb