Sha256: 66e1a2560aa8e961137a40b46d74d00c499d81a97f6b2d2022562cc5997285c2
Contents?: true
Size: 999 Bytes
Versions: 34
Compression:
Stored size: 999 Bytes
Contents
class Invitation < ApplicationRecord include Mumuki::Domain::Syncable, WithGeneratedCode belongs_to :course validate :ensure_not_expired, on: :create def ensure_not_expired errors.add(:base, :invitation_expired) if expired? end def import_from_resource_h!(json) update! json.merge(course: Course.locate!(json[:course])) end def organization course.organization end def course_slug course.slug end def navigable_name I18n.t(:invitation_for, course: course_name) end def to_resource_h {code: code, course: course_slug, expiration_date: expiration_date} end def navigation_end? true end def to_param code end def expired? expiration_date.past? end def unexpired raise Mumuki::Domain::GoneError, "This invitation has already expired" if expired? self end private def self.code_size 4 end def course_name course.name end def self.sync_key_id_field :code end end
Version data entries
34 entries across 34 versions & 1 rubygems