<commit_before>module RailsMoney
  def method_missing( method_id, *args )
    method_name = method_id.to_s
    setter = method_name.chomp!("=")
    method_name = "#{method_name}_in_cents"

    if @attributes.include?(method_name)
      if setter
        money = args.first.kind_of?(Money) ? args.first : Money.new(args.first)
        write_attribute(method_name,money.cents) 
      else
        Money.create_from_cents(read_attribute(method_name))      
      end
    else 
      super
    end
  end
 
  def respond_to?( method, include_private = false )
    method_name = method.to_s.chomp("=")
    @attributes.include?("#{method_name}_in_cents") || super
  end
end

ActiveRecord::Base.send :include, RailsMoney<commit_msg>* With these changes database column names do not  need to be changed * Works through Associations & regular object  pulls from the find methods * Will require each model that  has Money Fields to update the model with  (Example:   money_format :rate_in_cents, :expense_in_cents) * Now a developer can see the public methods  for  the "field"_in_cents on the model when typing  model.public_methods   (Should show "field" and "field=")<commit_after>class ActiveRecord::Base
  def self.money_format(*fields)
    fields.each do |field|
      temp_field = field.to_s.sub(/(_in_cents)/,"")
      define_method("#{temp_field}=") do |value|
        money = value.kind_of?(Money) ? value : Money.new(value)
        return self.send("#{temp_field}_in_cents=",money.cents)
      end
      define_method("#{temp_field}") do
        return Money.create_from_cents(self.send("#{temp_field}_in_cents")) 
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10596833130328867, 'fraction_numerical': 0.0, 'mean_word_length': 3.6543909348441925, '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': '6790418', 'n_tokens_mistral': 532, 'n_tokens_neox': 509, 'n_words': 129}