Class: Trestle::Toolbar::Link

Inherits:
Item
  • Object
show all
Defined in:
lib/trestle/toolbar/item.rb

Instance Attribute Summary collapse

Attributes inherited from Item

#label, #menu

Instance Method Summary collapse

Methods inherited from Item

#==, #button_classes, #button_label, #button_style, #button_style_classes, #options, #render_menu, #to_s

Constructor Details

#initialize(template, label, instance_or_url = {}, options = {}, &block) ⇒ Link

Returns a new instance of Link.


80
81
82
83
84
85
86
87
# File 'lib/trestle/toolbar/item.rb', line 80

def initialize(template, label, instance_or_url={}, options={}, &block)
  if instance_or_url.is_a?(Hash)
    super(template, label, instance_or_url, &block)
  else
    super(template, label, options, &block)
    @instance_or_url = instance_or_url
  end
end

Instance Attribute Details

#instance_or_urlObject (readonly)

Returns the value of attribute instance_or_url


78
79
80
# File 'lib/trestle/toolbar/item.rb', line 78

def instance_or_url
  @instance_or_url
end

Instance Method Details

#renderObject


89
90
91
92
93
94
95
# File 'lib/trestle/toolbar/item.rb', line 89

def render
  if @instance_or_url
    admin_link_to(button_label(label, options), instance_or_url, options)
  else
    admin_link_to(button_label(label, options), options)
  end
end