Class: Cats::Core::Store

Inherits:
ApplicationRecord show all
Defined in:
app/models/cats/core/store.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



50
51
52
# File 'app/models/cats/core/store.rb', line 50

def self.ransackable_associations(_auth_object = nil)
  %w[stacks warehouse]
end

.ransackable_attributes(_auth_object = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/cats/core/store.rb', line 32

def self.ransackable_attributes(_auth_object = nil)
  %w[
    available_space
    code
    gangway_corner_dist
    gangway_length
    gangway_width
    has_gangway
    height
    length
    name
    temporary
    usable_space
    warehouse_id
    width
  ]
end

Instance Method Details

#update_usable_spaceObject



26
27
28
29
30
# File 'app/models/cats/core/store.rb', line 26

def update_usable_space
  self.usable_space = (length - 2) * (width - 2)
  self.usable_space -= (gangway_length * gangway_width) if has_gangway
  self.available_space = self.usable_space
end

#validate_locationObject



20
21
22
23
24
# File 'app/models/cats/core/store.rb', line 20

def validate_location
  return if warehouse.nil?

  errors.add(:warehouse, "must be a valid warehouse") unless warehouse.location_type == Location::WAREHOUSE
end