<commit_before>class User < Sequel::Model
  include GDS::SSO::User

  plugin :serialization

  serialize_attributes :yaml, :permissions

  module Permissions
    SIGNIN = 'signin'
    HMRC_EDITOR = 'HMRC Editor'
    GDS_EDITOR = 'GDS Editor'
  end

  def self.find_for_gds_oauth(auth_hash)
    user_params = user_params_from_auth_hash(auth_hash)

    # update details of existing user
    if user = find(uid: auth_hash["uid"])
      user.update(user_params)
    else # Create a new user.
      create(user_params)
    end
  end

  def self.user_params_from_auth_hash(auth_hash)
    GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash)
  end

  def self.find_by_uid(uid)
    find(uid: uid)
  end

  def self.create!(attrs)
    create(attrs)
  end

  def gds_editor?
    has_permission?(Permissions::GDS_EDITOR)
  end

  def hmrc_editor?
    has_permission?(Permissions::HMRC_EDITOR)
  end

  def remotely_signed_out?
    remotely_signed_out
  end

  def update_attribute(attribute, value)
    update({ attribute => value })
  end

  def update_attributes(attributes)
    update(attributes)
  end
end<commit_msg>return `self` on User#update_attributes<commit_after>class User < Sequel::Model
  include GDS::SSO::User

  plugin :serialization

  serialize_attributes :yaml, :permissions

  module Permissions
    SIGNIN = 'signin'
    HMRC_EDITOR = 'HMRC Editor'
    GDS_EDITOR = 'GDS Editor'
  end

  def self.find_for_gds_oauth(auth_hash)
    user_params = user_params_from_auth_hash(auth_hash)

    # update details of existing user
    if user = find(uid: auth_hash["uid"])
      user.update_attributes(user_params)
    else # Create a new user.
      create(user_params)
    end
  end

  def self.user_params_from_auth_hash(auth_hash)
    GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash)
  end

  def self.find_by_uid(uid)
    find(uid: uid)
  end

  def self.create!(attrs)
    create(attrs)
  end

  def gds_editor?
    has_permission?(Permissions::GDS_EDITOR)
  end

  def hmrc_editor?
    has_permission?(Permissions::HMRC_EDITOR)
  end

  def remotely_signed_out?
    remotely_signed_out
  end

  def update_attribute(attribute, value)
    update({ attribute => value })
  end

  def update_attributes(attributes)
    update(attributes)
    self
  end
end
{'fraction_non_alphanumeric': 0.08369851007887817, 'fraction_numerical': 0.0, 'mean_word_length': 3.8266384778012683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4356899', 'n_tokens_mistral': 823, 'n_tokens_neox': 802, 'n_words': 163}