Class: Label
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Label
- Includes:
- Housekeeping, Shared::Depictions, Shared::IsData, Shared::Notes, Shared::PolymorphicAnnotator, Shared::Tags
- Defined in:
- app/models/label.rb
Overview
Text to be printed.
Defined Under Namespace
Classes: Code128, Generated, QrCode
Instance Attribute Summary collapse
-
#is_copy_edited ⇒ Boolean?
A curator assertion that the label has been checked and is ready for print.
-
#is_printed ⇒ Boolean?
When true the label has been sent to the printed, as asserted by the curator.
-
#label_object_id ⇒ String
Polymorphic id.
-
#label_object_type ⇒ String
Polymorphic type.
-
#style ⇒ String
The unique name for a corresponding CSS class.
-
#text ⇒ String
The text of the label.
-
#text_method ⇒ Object
Returns the value of attribute text_method.
-
#total ⇒ Integer
The number of copies to print.
Instance Method Summary collapse
- #is_generated? ⇒ Boolean
- #set_text ⇒ Object protected
- #stub_text ⇒ Object protected
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
Instance Attribute Details
#is_copy_edited ⇒ Boolean?
Returns 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_printed ⇒ Boolean?
Returns 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_id ⇒ String
Returns 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_type ⇒ String
Returns 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 |
#style ⇒ String
Returns 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 |
#text ⇒ String
Returns 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_method ⇒ Object
Returns the value of attribute text_method.
44 45 46 |
# File 'app/models/label.rb', line 44 def text_method @text_method end |
#total ⇒ Integer
Returns 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
54 55 56 |
# File 'app/models/label.rb', line 54 def is_generated? false end |
#set_text ⇒ Object (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_text ⇒ Object (protected)
64 65 66 |
# File 'app/models/label.rb', line 64 def stub_text assign_attributes(text: 'STUB') end |