Class: Note

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

Overview

A note is a text annotation on a data instance (record).

Notes are text only annotations on instances that belong to some project (i.e. models that include Housekeeping::Projects). Notes can not be cited.

To annotate global (models that do not include Housekeeping::Projects) instances use a DataAttribute.

#@!attribute note_object_attribute

@return [String]
  The specific attribute being annotated.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::PolymorphicAnnotator

#annotated_object_is_persisted?

Methods included from Shared::Tags

#reject_tags, #tag_with, #tagged?, #tagged_with?

Methods included from Shared::AttributeAnnotations

#annotated_column, #annotated_value_is_not_identical_to_attribute, #annotation_value, #attribute_to_annotate_is_valid_for_object, #original_value

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#note_object_idString

Returns The object id being annotated.

Returns:

  • (String)

    The object id being annotated



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/note.rb', line 27

class Note < ApplicationRecord
  # Notes can not be cited!
  include Housekeeping
  include Shared::AttributeAnnotations
  include Shared::Tags
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates(:note_object)
  ignore_whitespace_on(:text)

  # Please DO NOT include the following, they get in the way
  # of the present housekeeping approach. A not null constraint exists
  # to catch these.
  #    validates_associated :note_object
  #    validates_presence_of :note_object_id, :note_object_type
  validates_presence_of :text
  validates_uniqueness_of :text, scope: [:note_object_id, :note_object_type, :project_id]

  def self.annotated_attribute_column
    :note_object_attribute
  end

  def self.annotation_value_column
    :text
  end

  # TODO: make a helper
  # Format a note
  def note_string
    "#{updated_at}: #{updater.name}: #{text}" + (note_object_attribute.blank? ? '' : "[on: #{note_object_attribute}]")
  end

end

#note_object_typeString

Returns The object type being annotated.

Returns:

  • (String)

    The object type being annotated



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/note.rb', line 27

class Note < ApplicationRecord
  # Notes can not be cited!
  include Housekeeping
  include Shared::AttributeAnnotations
  include Shared::Tags
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates(:note_object)
  ignore_whitespace_on(:text)

  # Please DO NOT include the following, they get in the way
  # of the present housekeeping approach. A not null constraint exists
  # to catch these.
  #    validates_associated :note_object
  #    validates_presence_of :note_object_id, :note_object_type
  validates_presence_of :text
  validates_uniqueness_of :text, scope: [:note_object_id, :note_object_type, :project_id]

  def self.annotated_attribute_column
    :note_object_attribute
  end

  def self.annotation_value_column
    :text
  end

  # TODO: make a helper
  # Format a note
  def note_string
    "#{updated_at}: #{updater.name}: #{text}" + (note_object_attribute.blank? ? '' : "[on: #{note_object_attribute}]")
  end

end

#project_idInteger

Returns:

  • (Integer)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/note.rb', line 27

class Note < ApplicationRecord
  # Notes can not be cited!
  include Housekeeping
  include Shared::AttributeAnnotations
  include Shared::Tags
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates(:note_object)
  ignore_whitespace_on(:text)

  # Please DO NOT include the following, they get in the way
  # of the present housekeeping approach. A not null constraint exists
  # to catch these.
  #    validates_associated :note_object
  #    validates_presence_of :note_object_id, :note_object_type
  validates_presence_of :text
  validates_uniqueness_of :text, scope: [:note_object_id, :note_object_type, :project_id]

  def self.annotated_attribute_column
    :note_object_attribute
  end

  def self.annotation_value_column
    :text
  end

  # TODO: make a helper
  # Format a note
  def note_string
    "#{updated_at}: #{updater.name}: #{text}" + (note_object_attribute.blank? ? '' : "[on: #{note_object_attribute}]")
  end

end

#textString

Returns The content of the note. Markdown is supported.

Returns:

  • (String)

    The content of the note. Markdown is supported.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/note.rb', line 27

class Note < ApplicationRecord
  # Notes can not be cited!
  include Housekeeping
  include Shared::AttributeAnnotations
  include Shared::Tags
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates(:note_object)
  ignore_whitespace_on(:text)

  # Please DO NOT include the following, they get in the way
  # of the present housekeeping approach. A not null constraint exists
  # to catch these.
  #    validates_associated :note_object
  #    validates_presence_of :note_object_id, :note_object_type
  validates_presence_of :text
  validates_uniqueness_of :text, scope: [:note_object_id, :note_object_type, :project_id]

  def self.annotated_attribute_column
    :note_object_attribute
  end

  def self.annotation_value_column
    :text
  end

  # TODO: make a helper
  # Format a note
  def note_string
    "#{updated_at}: #{updater.name}: #{text}" + (note_object_attribute.blank? ? '' : "[on: #{note_object_attribute}]")
  end

end

Class Method Details

.annotated_attribute_columnObject



46
47
48
# File 'app/models/note.rb', line 46

def self.annotated_attribute_column
  :note_object_attribute
end

.annotation_value_columnObject



50
51
52
# File 'app/models/note.rb', line 50

def self.annotation_value_column
  :text
end

Instance Method Details

#note_stringObject

TODO: make a helper Format a note



56
57
58
# File 'app/models/note.rb', line 56

def note_string
  "#{updated_at}: #{updater.name}: #{text}" + (note_object_attribute.blank? ? '' : "[on: #{note_object_attribute}]")
end