Sha256: f614f589c04bb5eb1960d24523d6eeb1bcc2fd28206a461323c5c3ffb53a23e6

Contents?: true

Size: 507 Bytes

Versions: 2

Compression:

Stored size: 507 Bytes

Contents

module PageMeta
  class Link
    def self.build(rel, options)
      klass_name = "::PageMeta::Link::#{rel.to_s.camelize}"
      klass = const_get(klass_name) rescue Link
      klass.new(rel, options)
    end

    attr_reader :rel, :options

    def initialize(rel, options)
      @rel = rel.to_s.dasherize
      @options = options
    end

    def render
      helpers.tag(:link, options.merge(rel: rel)) unless options.empty?
    end

    def helpers
      ActionController::Base.helpers
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_meta-0.1.1 lib/page_meta/link.rb
page_meta-0.1.0 lib/page_meta/link.rb