Class: BardStatic::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:



31
32
33
34
35
36
37
38
# File 'app/helpers/bard_static/link_to_helper.rb', line 31

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.



44
45
46
# File 'app/helpers/bard_static/link_to_helper.rb', line 44

def context
  @context
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



44
45
46
# File 'app/helpers/bard_static/link_to_helper.rb', line 44

def html_options
  @html_options
end

#nameObject (readonly)

Returns the value of attribute name.



44
45
46
# File 'app/helpers/bard_static/link_to_helper.rb', line 44

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



44
45
46
# File 'app/helpers/bard_static/link_to_helper.rb', line 44

def options
  @options
end

Class Method Details

.render(*args, &block) ⇒ Object



23
24
25
26
27
28
29
# File 'app/helpers/bard_static/link_to_helper.rb', line 23

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

Instance Method Details

#renderObject



40
41
42
# File 'app/helpers/bard_static/link_to_helper.rb', line 40

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

#urlObject



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

def url
  context.url_for(options)
end