class ActionCrud::Helpers::Link
Attributes
action[RW]
label[RW]
options[RW]
record[RW]
Public Class Methods
new(context, record = nil, action = nil, *args)
click to toggle source
# File lib/action_crud/helpers/link.rb, line 6 def initialize(context, record = nil, action = nil, *args) @options = args.extract_options! @context = context @record = record || @context.try(:current_record) @action = action @label = options.fetch :label, nil @options = options.except :label @options.reverse_merge!(method: :delete, data: { confirm: 'Are you sure?' }) if delete? end
Public Instance Methods
action_label()
click to toggle source
# File lib/action_crud/helpers/link.rb, line 21 def action_label label || "#{action}".humanize end
delete?()
click to toggle source
# File lib/action_crud/helpers/link.rb, line 17 def delete? action.in? [:delete, :destroy] end
record_path()
click to toggle source
# File lib/action_crud/helpers/link.rb, line 25 def record_path ActionCrud::Helpers::Route.new(@context, record, action).path || "#{action}" end
render()
click to toggle source
# File lib/action_crud/helpers/link.rb, line 43 def render @context.link_to action_label, record_path, options if record_path.present? end
render_multiple(*args)
click to toggle source
# File lib/action_crud/helpers/link.rb, line 29 def render_multiple(*args) default = options options = args.extract_options! actions = args.concat(action).concat(options.keys) links = actions.uniq.map do |item| args = Hash(options[item]).reverse_merge(default) args = args.merge(class: "#{default[:class]} #{args[:class]}".strip) ActionCrud::Helpers::Link.new(@context, record, item, args).render end links.join.html_safe end