Class: Depiction

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::DataAttributes, Shared::IsData, Shared::PolymorphicAnnotator, Shared::Tags
Defined in:
app/models/depiction.rb

Overview

A depiction is the linkage between an image and a data object. For example an image may depiction a ColletingEvent, CollectionObject, or OTU.

Instance Attribute Summary (collapse)

Method Summary

Methods included from Housekeeping

#has_polymorphic_relationship?

Instance Attribute Details

- (Integer) depiction_object_id

Returns the id of the object being depicted

Returns:

  • (Integer)

    the id of the object being depicted



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/depiction.rb', line 20

class Depiction < ApplicationRecord
  # TODO: add position scoping

  include Housekeeping
  include Shared::Tags
  include Shared::DataAttributes
  include Shared::IsData
  include Shared::PolymorphicAnnotator
  polymorphic_annotates(:depiction_object)

  acts_as_list scope: [:project_id, :depiction_object_type, :depiction_object_id]

  belongs_to :image, inverse_of: :depictions
  has_one :sqed_depiction, dependent: :destroy

  accepts_nested_attributes_for :image

  accepts_nested_attributes_for :sqed_depiction, allow_destroy: true

  # This seems OK given specs, though similar validations in other concerns have created headaches.
  validates_presence_of :depiction_object

end

- (String) depiction_object_type

Returns the type of object being depicted, a TW class that can be depicted (e.g. CollectionObject, CollectingEvent)

Returns:

  • (String)

    the type of object being depicted, a TW class that can be depicted (e.g. CollectionObject, CollectingEvent)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/depiction.rb', line 20

class Depiction < ApplicationRecord
  # TODO: add position scoping

  include Housekeeping
  include Shared::Tags
  include Shared::DataAttributes
  include Shared::IsData
  include Shared::PolymorphicAnnotator
  polymorphic_annotates(:depiction_object)

  acts_as_list scope: [:project_id, :depiction_object_type, :depiction_object_id]

  belongs_to :image, inverse_of: :depictions
  has_one :sqed_depiction, dependent: :destroy

  accepts_nested_attributes_for :image

  accepts_nested_attributes_for :sqed_depiction, allow_destroy: true

  # This seems OK given specs, though similar validations in other concerns have created headaches.
  validates_presence_of :depiction_object

end

- (Integer) image_id

Returns the id of the image that stores the depiction

Returns:

  • (Integer)

    the id of the image that stores the depiction



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/depiction.rb', line 20

class Depiction < ApplicationRecord
  # TODO: add position scoping

  include Housekeeping
  include Shared::Tags
  include Shared::DataAttributes
  include Shared::IsData
  include Shared::PolymorphicAnnotator
  polymorphic_annotates(:depiction_object)

  acts_as_list scope: [:project_id, :depiction_object_type, :depiction_object_id]

  belongs_to :image, inverse_of: :depictions
  has_one :sqed_depiction, dependent: :destroy

  accepts_nested_attributes_for :image

  accepts_nested_attributes_for :sqed_depiction, allow_destroy: true

  # This seems OK given specs, though similar validations in other concerns have created headaches.
  validates_presence_of :depiction_object

end

- (Integer) project_id

Returns the project ID

Returns:

  • (Integer)

    the project ID



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/depiction.rb', line 20

class Depiction < ApplicationRecord
  # TODO: add position scoping

  include Housekeeping
  include Shared::Tags
  include Shared::DataAttributes
  include Shared::IsData
  include Shared::PolymorphicAnnotator
  polymorphic_annotates(:depiction_object)

  acts_as_list scope: [:project_id, :depiction_object_type, :depiction_object_id]

  belongs_to :image, inverse_of: :depictions
  has_one :sqed_depiction, dependent: :destroy

  accepts_nested_attributes_for :image

  accepts_nested_attributes_for :sqed_depiction, allow_destroy: true

  # This seems OK given specs, though similar validations in other concerns have created headaches.
  validates_presence_of :depiction_object

end