Sha256: d3a54377473bb3bf4890d6349f5384e279ee60a52ca23c87ecab02c9b3063b3d

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

module It
  # A class for links
  class Link < Tag
    include ActionView::Helpers::UrlHelper

    attr_reader :href

    # See It.link for details. You can do everything there and save 6 characters.
    def initialize(href, options = {})
      raise TypeError, 'Invalid href given' unless [Hash, String, ActiveSupport::SafeBuffer].include?(href.class)

      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

1 entries across 1 versions & 1 rubygems

Version Path
it-2.0.0 lib/it/link.rb