Class: Bootstrap::ActiveLinkTo::ActiveLink

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap/active_link_to.rb

Constant Summary collapse

ACTIVE_OPTIONS =
[:active, :class_active, :class_inactive, :active_disable]

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ActiveLink

Returns a new instance of ActiveLink.



8
9
10
# File 'lib/bootstrap/active_link_to.rb', line 8

def initialize(context)
  @context = context
end

Instance Method Details

#render(*args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bootstrap/active_link_to.rb', line 12

def render(*args, &block)
  @name           = block_given? ? capture(&block) : args.shift
  @link_options   = args.extract_options!
  @url            = h.url_for(args.shift)
  @active_options = @link_options.extract!(*ACTIVE_OPTIONS).only_presented
  @after_link     = @link_options.delete(:after_link).to_s
  
  if is_wrap?
    provide_wrap_with_content!
  else
    @link_options.smart_append_to :class, active_class
    content
  end
end