<commit_before>require "tryit/version"

class TryIt
  class << self
    attr_accessor :exceptions, :handler
  end

  @exceptions = [NoMethodError]
  @handler = lambda { |e| puts e.message }
end

class Object
  def tryit(*args, &block)
    if args.empty? && block_given?
      instance_eval &block
    else
      send(*args, &block)
    end
  rescue *TryIt.exceptions => e
    TryIt.handler.call(e)
  end
end<commit_msg>Change standard behavior to mirror Rails' #try.<commit_after>require "tryit/version"

class TryIt
  class << self
    attr_accessor :exceptions, :handler
  end

  @exceptions = [NoMethodError]
  @handler = lambda { |_| nil }
end

class Object
  def tryit(*args, &block)
    if args.empty? && block_given?
      instance_eval &block
    else
      send(*args, &block)
    end
  rescue *TryIt.exceptions => e
    TryIt.handler.call(e)
  end
end
{'fraction_non_alphanumeric': 0.1091753774680604, 'fraction_numerical': 0.0, 'mean_word_length': 3.2254901960784315, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6905717', 'n_tokens_mistral': 299, 'n_tokens_neox': 295, 'n_words': 79}