Class: WrapIt::Link

Inherits:
Base
  • Object
show all
Includes:
TextContainer
Defined in:
lib/wrap_it/link.rb

Overview

Link

Instance Attribute Summary

Attributes included from TextContainer

#body

Attributes inherited from Base

#options, #tag

Instance Method Summary collapse

Methods included from TextContainer

included

Methods inherited from Base

#initialize, #omit_content?, #render, #unwrap, #wrap

Methods included from Renderer

included

Methods included from Enums

included

Methods included from DerivedAttributes

included

Methods included from Switches

included

Methods included from HTMLData

included, #remove_html_data, #set_html_data

Methods included from HTMLClass

#add_html_class, #html_class, #html_class=, #html_class?, #html_class_prefix, included, #no_html_class?, #remove_html_class, sanitize

Methods included from Sections

#[], #[]=, included

Methods included from Callbacks

included, #run_callbacks

Constructor Details

This class inherits a constructor from WrapIt::Base

Instance Method Details

#hrefObject



12
13
14
# File 'lib/wrap_it/link.rb', line 12

def href
  @options[:href]
end

#href=(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wrap_it/link.rb', line 16

def href=(value)
  if value.is_a?(Hash)
    defined?(Rails) || fail(
      ArgumentError,
      'Hash links supported only in Rails env'
    )
    value = @template.url_for(value)
  end
  value.is_a?(String) || fail(ArgumentError, 'Wrong link type')
  @options[:href] = value
end