Class: Aureus::DataTableRowButton

Inherits:
Renderable show all
Defined in:
lib/aureus/data_table.rb

Instance Method Summary collapse

Methods inherited from Renderable

#compact, #compact_render, #content_tag, #init

Constructor Details

#initialize(type, text, url, options) ⇒ DataTableRowButton

Returns a new instance of DataTableRowButton.



120
121
122
123
124
125
# File 'lib/aureus/data_table.rb', line 120

def initialize type, text, url, options
  init options, :remote => true, :confirm => "Delete resource?"
  @type = type
  @text = text
  @url = url
end

Instance Method Details

#renderObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/aureus/data_table.rb', line 127

def render
  case @type
  when :text
    link_to @text, @url
  when :print
    link_to @text, @url, :class => :print
  when :show
    link_to @text, @url, :class => :show
  when :edit 
    link_to @text, @url, :class => :edit
  when :destroy
    if @options[:remote]
      link_to @text, @url, :class => :destroy, :method => :delete, :data => { :confirm => @options[:confirm] }
    else
      link_to @text, @url, :class => :destroy
    end
  end
end