<commit_before>require "drafteable/version"

module Drafteable
  def acts_as_drafteable
    include InstanceMethods
  end

  module InstanceMethods

    def published?
      begin
        !self.draft
      rescue NoMethodError
        raise Exception.new('There is no draft field. Did you forget to run migrations?')
      end
    end

    def draft!
      self.update_attribute(:draft, true)
    end

    def publish!
      self.update_attribute(:draft, false)
    end

  end

  ActiveRecord::Base.extend Drafteable
end<commit_msg>model.draft! skips validation<commit_after>require "drafteable/version"

module Drafteable
  def acts_as_drafteable
    include InstanceMethods
  end

  module InstanceMethods

    def published?
      begin
        !self.draft
      rescue NoMethodError
        raise Exception.new('There is no draft field. Did you forget to run migrations?')
      end
    end

    def draft!
      self.draft = true
      self.save(validation: false)
    end

    def publish!
      self.draft = false
      self.save
    end

  end

  ActiveRecord::Base.extend Drafteable
end
{'fraction_non_alphanumeric': 0.057534246575342465, 'fraction_numerical': 0.0, 'mean_word_length': 2.570032573289902, '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': '7084140', 'n_tokens_mistral': 328, 'n_tokens_neox': 315, 'n_words': 94}