Class: Invitation
Instance Method Summary
collapse
#platform_class_name, #sync_key
active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_pg_retry, with_temporary_token
Methods included from WithPgLock
#with_pg_lock
Instance Method Details
#course_slug ⇒ Object
21
22
23
|
# File 'app/models/invitation.rb', line 21
def course_slug
course.slug
end
|
#ensure_not_expired ⇒ Object
9
10
11
|
# File 'app/models/invitation.rb', line 9
def ensure_not_expired
errors.add(:base, :invitation_expired) if expired?
end
|
#expired? ⇒ Boolean
41
42
43
|
# File 'app/models/invitation.rb', line 41
def expired?
expiration_date.past?
end
|
#import_from_resource_h!(json) ⇒ Object
13
14
15
|
# File 'app/models/invitation.rb', line 13
def import_from_resource_h!(json)
update! json.merge(course: Course.locate!(json[:course]))
end
|
#navigable_name ⇒ Object
25
26
27
|
# File 'app/models/invitation.rb', line 25
def navigable_name
I18n.t(:invitation_for, course: course_name)
end
|
#navigation_end? ⇒ Boolean
33
34
35
|
# File 'app/models/invitation.rb', line 33
def navigation_end?
true
end
|
#organization ⇒ Object
17
18
19
|
# File 'app/models/invitation.rb', line 17
def organization
course.organization
end
|
#to_param ⇒ Object
37
38
39
|
# File 'app/models/invitation.rb', line 37
def to_param
code
end
|
#to_resource_h ⇒ Object
29
30
31
|
# File 'app/models/invitation.rb', line 29
def to_resource_h
{code: code, course: course_slug, expiration_date: expiration_date}
end
|
#unexpired ⇒ Object
45
46
47
48
|
# File 'app/models/invitation.rb', line 45
def unexpired
raise Mumuki::Domain::GoneError, "This invitation has already expired" if expired?
self
end
|