Class: Bard::Static::LinkToHelper::LinkTo

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/bard/static/link_to_helper.rb

Direct Known Subclasses

LinkToCurrent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, name, options = {}, html_options = {}) {|_self| ... } ⇒ LinkTo

Returns a new instance of LinkTo.

Yields:

  • (_self)

Yield Parameters:



33
34
35
36
37
38
39
40
# File 'app/helpers/bard/static/link_to_helper.rb', line 33

def initialize context, name, options = {}, html_options = {}, &block
  @context = context
  @name         = name
  @options      = options || {}
  @html_options = HashWithIndifferentAccess.new(html_options)
  @html_options = @context.send(:convert_options_to_data_attributes, @options, @html_options)
  yield self if block_given?
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



46
47
48
# File 'app/helpers/bard/static/link_to_helper.rb', line 46

def context
  @context
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



46
47
48
# File 'app/helpers/bard/static/link_to_helper.rb', line 46

def html_options
  @html_options
end

#nameObject (readonly)

Returns the value of attribute name.



46
47
48
# File 'app/helpers/bard/static/link_to_helper.rb', line 46

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



46
47
48
# File 'app/helpers/bard/static/link_to_helper.rb', line 46

def options
  @options
end

Class Method Details

.render(*args, &block) ⇒ Object



25
26
27
28
29
30
31
# File 'app/helpers/bard/static/link_to_helper.rb', line 25

def self.render *args, &block
  if block_given?
    new(*args, &block).render
  else
    new(*args).render
  end
end

Instance Method Details

#renderObject



42
43
44
# File 'app/helpers/bard/static/link_to_helper.rb', line 42

def render
  "<a #{href_attr}#{tag_options}>#{body}</a>".html_safe
end

#urlObject



48
49
50
# File 'app/helpers/bard/static/link_to_helper.rb', line 48

def url
  context.url_for(options)
end