<commit_before>module PdfHelper
  require 'prince'
  
  def self.included(base)
    base.class_eval do
      alias_method_chain :render, :princely
    end
  end
  
  def render_with_princely(options = nil, *args, &block)
    if options.nil? or options[:pdf].nil?
      render_without_princely(options, *args, &block)
    else
      options[:name] ||= options.delete(:pdf)
      make_and_send_pdf(options.delete(:name), options)
    end
  end  
    
  private
  
  def make_pdf(options = {})<commit_msg>Fixed conditions for rendering without princely.<commit_after>module PdfHelper
  require 'prince'
  
  def self.included(base)
    base.class_eval do
      alias_method_chain :render, :princely
    end
  end
  
  def render_with_princely(options = nil, *args, &block)
    if options.nil? or options.is_a?(Symbol) or (options.is_a?(Hash) and options[:pdf].nil?) then
      render_without_princely(options, *args, &block)
    else
      options[:name] ||= options.delete(:pdf)
      make_and_send_pdf(options.delete(:name), options)
    end
  end  
    
  private
  
  def make_pdf(options = {})
{'fraction_non_alphanumeric': 0.108675799086758, 'fraction_numerical': 0.0, 'mean_word_length': 3.384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6154480', 'n_tokens_mistral': 374, 'n_tokens_neox': 368, 'n_words': 80}