<commit_before>module Flex
  module Persistence
    module Storage

      module ClassMethods

        def create(args={})
          document = new(args)
          return false unless document.valid?
          document.save
        end

      end


      module InstanceMethods

        def reload
          document        = flex.get
          self.attributes = document['_source']
          @_id            = document['_id']
          @_version       = document['_version']
        end

        def save(vars={})
          return false unless valid?
          run_callbacks :save do
            run_callbacks(new_record? ? :create : :update) { do_save(vars) }
          end
          self
        end

        # Optimistic Lock Update
        #
        #    doc.lock_update do |d|
        #      d.amount += 100
        #    end
        #
        # if you are trying to update a stale object, the block is yielded again with a fresh reloaded document and the<commit_msg>create accepts vars<commit_after>module Flex
  module Persistence
    module Storage

      module ClassMethods

        def create(args={}, vars={})
          document = new(args)
          return false unless document.valid?
          document.save(vars)
        end

      end


      module InstanceMethods

        def reload
          document        = flex.get
          self.attributes = document['_source']
          @_id            = document['_id']
          @_version       = document['_version']
        end

        def save(vars={})
          return false unless valid?
          run_callbacks :save do
            run_callbacks(new_record? ? :create : :update) { do_save(vars) }
          end
          self
        end

        # Optimistic Lock Update
        #
        #    doc.lock_update do |d|
        #      d.amount += 100
        #    end
        #
        # if you are trying to update a stale object, the block is yielded again with a fresh reloaded document and the
{'fraction_non_alphanumeric': 0.07022900763358779, 'fraction_numerical': 0.0030534351145038168, 'mean_word_length': 1.4886075949367088, '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': '904029', 'n_tokens_mistral': 519, 'n_tokens_neox': 490, 'n_words': 158}