<commit_before># Creats a <ul class="crud_links"> with links as list items.
# Use like so: <%= CrudLinks.new(self, @controller, @link_options).to_html {yield :yr_blk} %>
# 
# Options are +controller_name+ and +hide+.
# 
#  To change behavior in a view: 
# 
#  crudlinks(:hide => true, :controller_name => 'foo') do
#    link_to 'home', admin_path
#    link_to 'vacation', vacation_path
#  end


module Crudlink::ViewHelper
  def crudlinks(options={}, &blk)
    @crudlink_options = options
    cap = block_given? ? capture(&blk) : ''
    content_for(:link_content) {cap}
  end
end


class Crudlinks  
  
  def initialize(template, controller, options={})
    options ||= {} # Don't ask
    @template, @controller = template, controller
    set_instance_by_controller_name
    @link_controller = (options[:controller_name] || @name.pluralize)
    @hide = (options[:hide] || false)
  end
  
  
  def edit_link
    path = {:controller => @link_controller, :action => "edit", :id => @instance}
    link_to("Edit #{@name.titleize}", path, :class => "button edit")
  end
  
  
  def extract_links(links="")
    @extra_links = links.split(",") rescue []
  end
  
  
  def delete_link
    path = {:controller => @link_controller, :action => "destroy", :id => @instance}
    link_to("Delete #{@name.titleize}", path, :confirm => 'Are you sure?', :method => :delete, :class => "button delete")<commit_msg>fixed split on comma thing with proper regex<commit_after># Creats a <ul class="crud_links"> with links as list items.
# Use like so: <%= CrudLinks.new(self, @controller, @link_options).to_html {yield :yr_blk} %>
# 
# Options are +controller_name+ and +hide+.
# 
#  To change behavior in a view: 
# 
#  crudlinks(:hide => true, :controller_name => 'foo') do
#    link_to 'home', admin_path
#    link_to 'vacation', vacation_path
#  end


module Crudlink::ViewHelper
  def crudlinks(options={}, &blk)
    @crudlink_options = options
    cap = block_given? ? capture(&blk) : ''
    content_for(:link_content) {cap}
  end
end


class Crudlinks  
  
  def initialize(template, controller, options={})
    options ||= {} # Don't ask
    @template, @controller = template, controller
    set_instance_by_controller_name
    @link_controller = (options[:controller_name] || @name.pluralize)
    @hide = (options[:hide] || false)
  end
  
  
  def edit_link
    path = {:controller => @link_controller, :action => "edit", :id => @instance}
    link_to("Edit #{@name.titleize}", path, :class => "button edit")
  end
  
  
  def extract_links(links="")
    @extra_links ||= links.scan(/<a.*?>.*?<\/a>/) rescue []
  end
  
  
  def delete_link
    path = {:controller => @link_controller, :action => "destroy", :id => @instance}
    link_to("Delete #{@name.titleize}", path, :confirm => 'Are you sure?', :method => :delete, :class => "button delete")
{'fraction_non_alphanumeric': 0.15919519943522767, 'fraction_numerical': 0.0, 'mean_word_length': 3.98943661971831, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2591636', 'n_tokens_mistral': 968, 'n_tokens_neox': 943, 'n_words': 244}