Class: Label

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Depictions, Shared::IsData, Shared::Notes, Shared::PolymorphicAnnotator, Shared::Tags
Defined in:
app/models/label.rb

Overview

Text to be printed.

Direct Known Subclasses

Code128, Generated, QrCode

Defined Under Namespace

Classes: Code128, Generated, QrCode

Instance Attribute 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::Depictions

#has_depictions?, #image_array=, #reject_depictions, #reject_images

Methods included from Shared::Tags

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

Methods included from Shared::Notes

#concatenated_notes_string, #reject_notes

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#is_copy_editedBoolean?

Returns A curator assertion that the label has been checked and is ready for print. Not required prior to printing.

Returns:

  • (Boolean, nil)

    A curator assertion that the label has been checked and is ready for print. Not required prior to printing.



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#is_printedBoolean?

Returns When true the label has been sent to the printed, as asserted by the curator.

Returns:

  • (Boolean, nil)

    When true the label has been sent to the printed, as asserted by the curator.



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#label_object_idString

Returns Polymorphic id.

Returns:

  • (String)

    Polymorphic id



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#label_object_typeString

Returns Polymorphic type.

Returns:

  • (String)

    Polymorphic type



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#styleString

Returns The unique name for a corresponding CSS class. # TODO: reference vocabulary file.

Returns:

  • (String)

    The unique name for a corresponding CSS class. # TODO: reference vocabulary file



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#textString

Returns The text of the label.

Returns:

  • (String)

    The text of the label.



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

#text_methodObject

Returns the value of attribute text_method.



44
45
46
# File 'app/models/label.rb', line 44

def text_method
  @text_method
end

#totalInteger

Returns The number of copies to print.

Returns:

  • (Integer)

    The number of copies to print



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
61
62
63
64
65
66
67
68
# File 'app/models/label.rb', line 31

class Label < ApplicationRecord

  include Housekeeping
  include Shared::Notes
  include Shared::Tags
  include Shared::Depictions
  include Shared::PolymorphicAnnotator
  include Shared::IsData

  polymorphic_annotates('label_object', presence_validate: false)

  ignore_whitespace_on(:text)

  attr_accessor :text_method

  before_validation :stub_text, if: Proc.new { |c| c.text_method.present? }

  after_save :set_text, if: Proc.new { |c| c.text_method.present? }

  validates_presence_of :text, :total

  scope :unprinted, -> { where(is_printed: false) }

  def is_generated?
    false
  end

  protected

  def set_text
    update_column(:text, label_object.reload.send(text_method.to_sym))
  end

  def stub_text
    assign_attributes(text:  'STUB')
  end

end

Instance Method Details

#is_generated?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/label.rb', line 54

def is_generated?
  false
end

#set_textObject (protected)



60
61
62
# File 'app/models/label.rb', line 60

def set_text
  update_column(:text, label_object.reload.send(text_method.to_sym))
end

#stub_textObject (protected)



64
65
66
# File 'app/models/label.rb', line 64

def stub_text
  assign_attributes(text:  'STUB')
end