<commit_before>module Casbah
  module Service
    class Base
      include ActiveModel::Validations
      include ActiveModel::Serializers::JSON

      attr_accessor :id, :url

      validates_presence_of :url, allow_blank:false

      def initialize( params = {} )
        self.url = params[:url]
      end

      def id
        "service.#{url}"
      end

      def url=( value )
        uri = Addressable::URI.parse( value ) if value.is_a? String

        @url = uri.origin if uri
      end<commit_msg>Sets instance variables when the initialization params don't match setter methods<commit_after>module Casbah
  module Service
    class Base
      include ActiveModel::Validations
      include ActiveModel::Serializers::JSON

      attr_accessor :id, :url

      validates_presence_of :url, allow_blank:false

      def initialize( params = {} )
        params.each do |k, v|
          if respond_to? "#{k}="
            self.send "#{k}=", v
          else
            instance_variable_set "@#{k}", v
          end
        end
      end

      def id
        "service.#{url}"
      end

      def url=( value )
        uri = Addressable::URI.parse( value ) if value.is_a? String

        @url = uri.origin if uri
      end
{'fraction_non_alphanumeric': 0.09120521172638436, 'fraction_numerical': 0.0, 'mean_word_length': 2.080200501253133, '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': '5688033', 'n_tokens_mistral': 359, 'n_tokens_neox': 349, 'n_words': 103}