Sha256: 6caab726c35c9413259d5d05e7104aa726306349e605448d5b7ea7dbf502716d

Contents?: true

Size: 549 Bytes

Versions: 13

Compression:

Stored size: 549 Bytes

Contents

module Samvera
  module Persona
    module UsernameBehavior 
      extend ActiveSupport::Concern
      included do
        before_create :check_for_mandatory
      end

      def check_for_mandatory
        if self.respond_to?(:username)
          if self.email.present? && self.username.blank?
            self.username = self.email
          end
        end

        if self.respond_to?(:uid)
          if self.email.present? && self.uid.blank?
            self.uid = self.email
          end
        end

        true
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
samvera-persona-0.5.0 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.4.1 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.4.0 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.3.0 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.2.0 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.7 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.6 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.5 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.4 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.3 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.2 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.1 app/models/concerns/samvera/persona/username_behavior.rb
samvera-persona-0.1.0 app/models/concerns/samvera/persona/username_behavior.rb