Class: Koi::Identity::Principal

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
app/models/koi/identity/principal.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dump(principal) ⇒ Object



9
10
11
# File 'app/models/koi/identity/principal.rb', line 9

def self.dump(principal)
  principal&.attributes&.to_json
end

.load(json) ⇒ Object



13
14
15
16
17
# File 'app/models/koi/identity/principal.rb', line 13

def self.load(json)
  return if json.blank?

  Principal.new(**JSON.parse(json).slice(*attribute_names))
end

Instance Method Details

#attributes_for_findObject



28
29
30
# File 'app/models/koi/identity/principal.rb', line 28

def attributes_for_find
  { email: }
end

#inspectObject Also known as: to_s



32
33
34
35
# File 'app/models/koi/identity/principal.rb', line 32

def inspect
  "<#{self.class.name} provider=#{provider.inspect} scope=#{scope.inspect} subject=#{subject.inspect} " \
    "name=#{name.inspect} email=#{email.inspect}>"
end