<commit_before>require 'bigdecimal'
require 'bigdecimal/util'

module CloudPayments
  class Model < Hashie::Trash
    include Hashie::Extensions::IgnoreUndeclared

    DateTimeTransform  = ->(v) { DateTime.parse(v) if v }
    DecimalTransform  = ->(v) { v.to_d if v }

    BooleanTransform  =
      lambda do |v|
        if v == true || v == false || v.nil?
          v
        elsif v == '0'.freeze
          false
        elsif v == '1'.freeze
          true
        end
      end

    IntegralTransform = ->(v) { v.to_i if v }
  end
end<commit_msg>Fix date transformer to accept dates<commit_after>require 'bigdecimal'
require 'bigdecimal/util'

module CloudPayments
  class Model < Hashie::Trash
    include Hashie::Extensions::IgnoreUndeclared

    DateTimeTransform = ->(v) { DateTime.parse(v) if v&.respond_to? :to_s }
    DecimalTransform  = ->(v) { v&.to_d }
    IntegralTransform = ->(v) { v&.to_i }
    BooleanTransform  = ->(v) { (v == '0') ? false : !!v }
  end
end
{'fraction_non_alphanumeric': 0.130879345603272, 'fraction_numerical': 0.003067484662576687, 'mean_word_length': 2.6394052044609664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '4103904', 'n_tokens_mistral': 338, 'n_tokens_neox': 328, 'n_words': 84}