<commit_before>module MerchantSidekick
  module Addressable
    # Super class of all types of addresses
    class Address < ActiveRecord::Base
      self.table_name = "addresses"

      #--- column mapping
      cattr_accessor :street_address_column
      @@street_address_column = :street

      cattr_accessor :city_column
      @@city_column = :city

      cattr_accessor :postal_code_column
      @@postal_code_column = :postal_code

      cattr_accessor :province_column
      @@province_column = :province

      cattr_accessor :province_code_column
      @@province_code_column = :province_code

      cattr_accessor :country_column
      @@country_column = :country

      cattr_accessor :country_code_column
      @@country_code_column = :country_code

      cattr_accessor :gender_column
      @@gender_column = :gender

      cattr_accessor :first_name_column
      @@first_name_column = :first_name

      cattr_accessor :middle_name_column
      @@middle_name_column = false

      cattr_accessor :last_name_column
      @@last_name_column = :last_name

      #--- associations
      belongs_to :addressable, :polymorphic => true

      #--- validations
      # extend your Address class with validation as you please

      #--- callbacks

      # This particular call back could be used to save
      # geocordinates if addressable defines :before_save_address method
      def before_save
        # trigger before_save_address
        self.addressable.send(:before_save_address, self) if addressable && addressable.respond_to?(:before_save_address)
      end

      #--- class methods

      class << self

        def kind
          name.underscore
        end

        # Returns the binding to be used in sub classes of Address
        def get_binding
          binding
        end

        # Helper class method to look up all addresss for
        # addressable class name and addressable id.
        def find_address_for_addressable(addressable_str, addressable_id)
          find(:all,
            :conditions => ["addressable_type = ? AND addressable_id = ?", addressable_str, addressable_id],
            :order => "created_at DESC"
          )
        end

        # Helper class method to look up a addressable object
        # given the addressable class name and id
        def find_addressable(addressable_str, addressable_id)
          addressable_str.constantize.find(addressable_id)
        end

        # attempt to make sanitize_sql public
        def sanitize_sql_with_key_translation(condition)
          sanitize_sql_without_key_translation(condition)
        end
        alias_method_chain :sanitize_sql, :key_translation

        # TODO not used
        def translate_column_key(in_column)
          out_column = class_variable_get("@@#{in_column}")
          case out_column.class.name
          when /NilClass/ then in_column
          when /FalseClass/ then nil
          else out_column
          end
        end

        def content_column_names
          content_columns.map(&:name) - %w(kind addressable_type addressable_id updated_at created_at)
        end

      end
<commit_msg>Getting rid of obsolete code<commit_after>module MerchantSidekick
  module Addressable
    # Super class of all types of addresses
    class Address < ActiveRecord::Base
      self.table_name = "addresses"

      #--- column mapping
      cattr_accessor :street_address_column
      @@street_address_column = :street

      cattr_accessor :city_column
      @@city_column = :city

      cattr_accessor :postal_code_column
      @@postal_code_column = :postal_code

      cattr_accessor :province_column
      @@province_column = :province

      cattr_accessor :province_code_column
      @@province_code_column = :province_code

      cattr_accessor :country_column
      @@country_column = :country

      cattr_accessor :country_code_column
      @@country_code_column = :country_code

      cattr_accessor :gender_column
      @@gender_column = :gender

      cattr_accessor :first_name_column
      @@first_name_column = :first_name

      cattr_accessor :middle_name_column
      @@middle_name_column = false

      cattr_accessor :last_name_column
      @@last_name_column = :last_name

      #--- associations
      belongs_to :addressable, :polymorphic => true

      #--- validations
      # extend your Address class with validation as you please

      #--- callbacks

      # This particular call back could be used to save
      # geocordinates if addressable defines :before_save_address method
      def before_save
        # trigger before_save_address
        self.addressable.send(:before_save_address, self) if addressable && addressable.respond_to?(:before_save_address)
      end

      #--- class methods

      class << self

        def kind
          name.underscore
        end

        # Returns the binding to be used in sub classes of Address
        def get_binding
          binding
        end

        # Helper class method to look up all addresss for
        # addressable class name and addressable id.
        def find_address_for_addressable(addressable_str, addressable_id)
          find(:all,
            :conditions => ["addressable_type = ? AND addressable_id = ?", addressable_str, addressable_id],
            :order => "created_at DESC"
          )
        end

        # Helper class method to look up a addressable object
        # given the addressable class name and id
        def find_addressable(addressable_str, addressable_id)
          addressable_str.constantize.find(addressable_id)
        end

        # TODO not used
        def translate_column_key(in_column)
          out_column = class_variable_get("@@#{in_column}")
          case out_column.class.name
          when /NilClass/ then in_column
          when /FalseClass/ then nil
          else out_column
          end
        end

        def content_column_names
          content_columns.map(&:name) - %w(kind addressable_type addressable_id updated_at created_at)
        end

      end

{'fraction_non_alphanumeric': 0.060304837640821736, 'fraction_numerical': 0.0, 'mean_word_length': 2.495657209033005, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7310719', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1650, 'n_words': 430}