<commit_before>module Abstractor
  module Methods
    module Models
      module AbstractorSuggestion
        def self.included(base)
          base.send :include, SoftDelete

          # Associations
          base.send :belongs_to, :abstractor_abstraction
          base.send :belongs_to, :abstractor_suggestion_status

          base.send :has_one, :abstractor_suggestion_object_value
          base.send :has_one, :abstractor_object_value, through: :abstractor_suggestion_object_value

          base.send :has_many, :abstractor_suggestion_sources, dependent: :destroy

          # base.send :attr_accessible, :abstractor_abstraction, :abstractor_abstraction_id, :abstractor_suggestion_sources, :abstractor_suggestion_source_id, :abstractor_suggestion_status, :abstractor_suggestion_status_id, :suggested_value, :deleted_at, :unknown, :not_applicable

          # Hooks
          base.send :after_save, :update_abstraction_value, :if => lambda {|abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status_id_changed?}
          base.send :after_save, :update_siblings_status, :if => lambda {|abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status_id_changed?}
        end

        # Instance Methods
        def update_abstraction_value
          if abstractor_suggestion_status.accepted?
            abstractor_abstraction.value                     = suggested_value
            abstractor_abstraction.unknown                   = unknown
            abstractor_abstraction.not_applicable            = not_applicable
            abstractor_abstraction.save!
          elsif abstractor_suggestion_status.needs_review?
            abstractor_abstraction.value          = nil
            abstractor_abstraction.unknown        = nil
            abstractor_abstraction.not_applicable = nil<commit_msg>References #84 Missed a dependent destroy.<commit_after>module Abstractor
  module Methods
    module Models
      module AbstractorSuggestion
        def self.included(base)
          base.send :include, SoftDelete

          # Associations
          base.send :belongs_to, :abstractor_abstraction
          base.send :belongs_to, :abstractor_suggestion_status

          base.send :has_one, :abstractor_suggestion_object_value, dependent: :destroy
          base.send :has_one, :abstractor_object_value, through: :abstractor_suggestion_object_value

          base.send :has_many, :abstractor_suggestion_sources, dependent: :destroy

          # base.send :attr_accessible, :abstractor_abstraction, :abstractor_abstraction_id, :abstractor_suggestion_sources, :abstractor_suggestion_source_id, :abstractor_suggestion_status, :abstractor_suggestion_status_id, :suggested_value, :deleted_at, :unknown, :not_applicable

          # Hooks
          base.send :after_save, :update_abstraction_value, :if => lambda {|abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status_id_changed?}
          base.send :after_save, :update_siblings_status, :if => lambda {|abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status_id_changed?}
        end

        # Instance Methods
        def update_abstraction_value
          if abstractor_suggestion_status.accepted?
            abstractor_abstraction.value                     = suggested_value
            abstractor_abstraction.unknown                   = unknown
            abstractor_abstraction.not_applicable            = not_applicable
            abstractor_abstraction.save!
          elsif abstractor_suggestion_status.needs_review?
            abstractor_abstraction.value          = nil
            abstractor_abstraction.unknown        = nil
            abstractor_abstraction.not_applicable = nil
{'fraction_non_alphanumeric': 0.05890263582571275, 'fraction_numerical': 0.0005379236148466917, 'mean_word_length': 3.155307262569832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3951253', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1008, 'n_words': 170}