Class: Degree

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/degree.rb

Overview

Model for handling degrees

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Hash{String => String, Number}) new_degree(year, degree_type, institution_name)

Creates a new degree

Parameters:

  • year (Number)

    year the degree was awarded

  • degree_type (String)

    type of the degree

  • institution_name (String)

    name of the institution the degree was awarded

Returns:

  • (Hash{String => String, Number})

    newly created degree



15
16
17
18
19
20
21
22
23
24
# File 'app/models/degree.rb', line 15

def Degree.new_degree(year, degree_type, institution_name)
  degree_type = degree_type.downcase
  institution_id = FindId.institution(institution_name)

  degree = Degree.create_with(approved: false)
                  .find_or_create_by(year: year,
                                      degree_type: degree_type,
                                      institution_id: institution_id)
  return degree
end

Instance Method Details

- (Object) as_json(options = {})

Handles rendering a degree in a JSON format.



27
28
29
# File 'app/models/degree.rb', line 27

def as_json(options={})
  super(:except => [:created_at, :updated_at])
end