Class: V1::AnnotationResource
- Inherits:
-
JSONAPI::Resource
- Object
- JSONAPI::Resource
- V1::AnnotationResource
- Defined in:
- app/resources/v1/annotation_resource.rb
Overview
Provides a JSON:API resource of Annotation model.
AnnotationResource represents a user-supplied comment or note attached to any annotatable resource. It allows creation of annotations, but updates and deletions are not permitted via the API.
Primary relationships:
-
annotation_type AnnotationTypeResource - The type/category of the annotation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#annotatable_id ⇒ Integer
The ID of the resource this annotation is attached to.
-
#annotatable_type ⇒ String
The type of the resource this annotation is attached to.
-
#annotation_type_id ⇒ Integer
The ID of the annotation type.
-
#comment ⇒ String
The annotation text (required, max 500 chars).
-
#created_at ⇒ DateTime
The timestamp when the annotation was created.
-
#user ⇒ String
The user who created the annotation (required, max 10 chars).
Instance Method Summary collapse
- #remove ⇒ Object
-
#replace_fields(_fields) ⇒ Object
Prevent updates and deletes through the API.
Instance Attribute Details
#annotatable_id ⇒ Integer
Returns the ID of the resource this annotation is attached to.
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
#annotatable_type ⇒ String
Returns the type of the resource this annotation is attached to.
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
#annotation_type_id ⇒ Integer
Returns the ID of the annotation type.
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
#comment ⇒ String
Returns the annotation text (required, max 500 chars).
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
#created_at ⇒ DateTime
Returns the timestamp when the annotation was created.
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
#user ⇒ String
Returns the user who created the annotation (required, max 10 chars).
51 |
# File 'app/resources/v1/annotation_resource.rb', line 51 attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id |
Instance Method Details
#remove ⇒ Object
64 65 66 |
# File 'app/resources/v1/annotation_resource.rb', line 64 def remove raise JSONAPI::Exceptions::RecordLocked, 'Annotations cannot be deleted' end |
#replace_fields(_fields) ⇒ Object
Prevent updates and deletes through the API
60 61 62 |
# File 'app/resources/v1/annotation_resource.rb', line 60 def replace_fields(_fields) raise JSONAPI::Exceptions::RecordLocked, 'Annotations cannot be updated' end |