Class: Boxenn::Entity

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/boxenn/entity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.primary_keysObject



10
11
12
# File 'lib/boxenn/entity.rb', line 10

def self.primary_keys
  raise UndefinePrimaryKeys.new(class_name: self.class.name)
end

Instance Method Details

#primary_keys_hashObject



14
15
16
17
18
19
20
# File 'lib/boxenn/entity.rb', line 14

def primary_keys_hash
  if self.class.primary_keys.all? { |s| attributes.key? s }
    attributes.slice(*self.class.primary_keys)
  else
    raise UnassignPrimaryKeys.new(class_name: self.class.name)
  end
end