<commit_before>module Catwalk
  module Presenter
    def self.included(base)
      base.send :extend, ClassMethods
    end

    def initialize(model)
      @model = model
    end

    define_method(:to_model)   { @model }
    define_method(:to_param)   { @model.to_param if persisted? }
    define_method(:to_key)     { @model.to_key   if persisted? }
    define_method(:persisted?) { @model.persisted? }
    define_method(:valid?)     { @model.valid? }
    define_method(:model_name) { @model.model_name }
    define_method(:errors)     { @model.errors }

    module ClassMethods

      def field(field_name,opts={})
        define_method field_name do
          field_value = @model.send field_name
          default_when = opts[:default_when]

          if default_when && field_value.send(default_when)
            "Not Set"
          else
            field_value
          end<commit_msg>implement format block<commit_after>module Catwalk
  module Presenter
    def self.included(base)
      base.send :extend, ClassMethods
    end

    def initialize(model)
      @model = model
    end

    define_method(:to_model)   { @model }
    define_method(:to_param)   { @model.to_param if persisted? }
    define_method(:to_key)     { @model.to_key   if persisted? }
    define_method(:persisted?) { @model.persisted? }
    define_method(:valid?)     { @model.valid? }
    define_method(:model_name) { @model.model_name }
    define_method(:errors)     { @model.errors }

    module ClassMethods

      def field(field_name,opts={})
        define_method field_name do
          field_value = @model.send field_name
          default_when = opts[:default_when]

          if default_when && field_value.send(default_when)
            "Not Set"
          elsif opts[:format_with] && opts[:format_with].respond_to?(:call)
            opts[:format_with].call field_value
          else
            field_value
          end
{'fraction_non_alphanumeric': 0.09953100573215216, 'fraction_numerical': 0.0, 'mean_word_length': 2.562152133580705, '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': '7024366', 'n_tokens_mistral': 585, 'n_tokens_neox': 569, 'n_words': 112}