Class: ApiMaker::PrimaryIdForModel

Inherits:
Object
  • Object
show all
Defined in:
app/services/api_maker/primary_id_for_model.rb

Class Method Summary collapse

Class Method Details

.get(model) ⇒ Object

Hack to get the primary ID or fail to make up for if the attribute wasn’t selected



3
4
5
# File 'app/services/api_maker/primary_id_for_model.rb', line 3

def self.get(model)
  model.id || raise("No attribute called '#{model.class.primary_key}' given on #{model.class.name}")
end