Class: Comable::StockLocation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/comable/stock_location.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject



14
15
16
17
18
# File 'app/models/comable/stock_location.rb', line 14

def default
  where(default: true).first_or_initialize do |stock_location|
    stock_location.name = Comable.t(:deafult)
  end
end

Instance Method Details

#as_json(_options = {}) ⇒ Object



21
22
23
# File 'app/models/comable/stock_location.rb', line 21

def as_json(_options = {})
  { id: id, text: name }
end

#find_stock_item(variant) ⇒ Object



25
26
27
# File 'app/models/comable/stock_location.rb', line 25

def find_stock_item(variant)
  stocks.find_by(variant: variant)
end