<commit_before>module Sentinel
  module Model
    attr_accessor :id

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      attr_accessor :entity_name, :fields

      # Fetch entity data based on entity Id
      #
      # @param id [Object] The key of the entity
      #
      def find(id)
        result = Sentinel.client.find(entity_name, id)

        klass = new

        klass.id = result.Id
        @fields.keys.each do |k|
          attribute = @fields[k]
          has_alias = attribute[:alias]
          field_name = has_alias ? attribute[:alias] : k

          klass.send("#{field_name}=", result.send(k))
        end

        return klass
      end

      # Create a new SalesForce entity row
      #
      # @param attrs [Hash] set of entity attributes
      #
      def create(attrs)
        Sentinel.client.create(entity_name, attrs)

        return true
      rescue
        return false
      end

      # Update an existing SalesForce entity row
      #
      # @param id [Object] corresponding entity id for updated
      # @param attrs [Hash] set of fields to update
      #
      def update(id, attrs)
        Sentinel.client.update(entity_name, id, attrs)

        return true
      rescue
        return false
      end

      # Declarative set the SalesForce entity model
      #
      # @param sentinel_table [Symbol] sales force entity model name
      #
      def set_sentinel_table sentinel_table
        self.entity_name = sentinel_table
      end

      # Return set of defined SalesForce fields
      def fields
        return @fields if instance_variable_defined?(:@fields) && @fields<commit_msg>fixed #update method<commit_after>module Sentinel
  module Model
    attr_accessor :id

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      attr_accessor :entity_name, :fields

      # Fetch entity data based on entity Id
      #
      # @param id [Object] The key of the entity
      #
      def find(id)
        result = Sentinel.client.find(entity_name, id)

        klass = new

        klass.id = result.Id
        @fields.keys.each do |k|
          attribute = @fields[k]
          has_alias = attribute[:alias]
          field_name = has_alias ? attribute[:alias] : k

          klass.send("#{field_name}=", result.send(k))
        end

        return klass
      end

      # Create a new SalesForce entity row
      #
      # @param attrs [Hash] set of entity attributes
      #
      def create(attrs)
        Sentinel.client.create(entity_name, attrs)

        return true
      rescue
        return false
      end

      # Update an existing SalesForce entity row
      #
      # @param id [Object] corresponding entity id for updated
      # @param attrs [Hash] set of fields to update
      #
      def update(id, attrs)
        Sentinel.client.update(entity_name, attrs.merge(Id: id))

        return true
      rescue
        return false
      end

      # Declarative set the SalesForce entity model
      #
      # @param sentinel_table [Symbol] sales force entity model name
      #
      def set_sentinel_table sentinel_table
        self.entity_name = sentinel_table
      end

      # Return set of defined SalesForce fields
      def fields
        return @fields if instance_variable_defined?(:@fields) && @fields
{'fraction_non_alphanumeric': 0.06974664679582712, 'fraction_numerical': 0.0, 'mean_word_length': 1.9964285714285714, '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': '5420173', 'n_tokens_mistral': 950, 'n_tokens_neox': 929, 'n_words': 295}