Class: Container

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Housekeeping, Shared::Containable, Shared::Identifiable, SoftValidation
Defined in:
app/models/container.rb

Direct Known Subclasses

Box, Cabinet, Drawer, Folder, Pin, Shelf, Slide, SlideBox, UnitTray, Vial, VialRack, Virtual

Defined Under Namespace

Classes: Box, Cabinet, Drawer, Folder, Pin, Shelf, Slide, SlideBox, UnitTray, Vial, VialRack, Virtual

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods included from Housekeeping

#has_polymorphic_relationship?

Class Method Details

.class_nameObject

Return a String with the “common” name for this class.



22
23
24
# File 'app/models/container.rb', line 22

def self.class_name
  self.name.demodulize.underscore.humanize.downcase
end

.valid_parentsObject



41
42
43
# File 'app/models/container.rb', line 41

def self.valid_parents
  CONTAINER_TYPE_NAMES
end

Instance Method Details

#type_classObject



35
36
37
38
39
# File 'app/models/container.rb', line 35

def type_class
  r = read_attribute(:type).to_s
  r = CONTAINER_TYPE_NAMES.include?(r) ? r.safe_constantize : nil
  r
end

#type_class=(value) ⇒ Object



31
32
33
# File 'app/models/container.rb', line 31

def type_class=(value)
  write_attribute(:type, value.to_s)
end

#type_nameObject



26
27
28
29
# File 'app/models/container.rb', line 26

def type_name
  r = self.type.to_s
  CONTAINER_TYPE_NAMES.include?(r) ? r : nil
end