Class: Dscf::Marketplace::Unit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Dscf::Marketplace::Unit
- Defined in:
- app/models/dscf/marketplace/unit.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering.
Instance Method Summary collapse
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
32 33 34 |
# File 'app/models/dscf/marketplace/unit.rb', line 32 def self.ransackable_associations(_auth_object = nil) %w[unit_conversions products supplier_products listings order_items rfq_items quotation_items] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering
28 29 30 |
# File 'app/models/dscf/marketplace/unit.rb', line 28 def self.ransackable_attributes(_auth_object = nil) %w[id code name unit_type created_at updated_at] end |
Instance Method Details
#convertible_to?(other_unit) ⇒ Boolean
40 41 42 43 44 45 46 |
# File 'app/models/dscf/marketplace/unit.rb', line 40 def convertible_to?(other_unit) return false if other_unit.nil? return true if id == other_unit.id unit_conversions.exists?(to_unit: other_unit) || other_unit.unit_conversions.exists?(to_unit: self) end |
#display_name ⇒ Object
36 37 38 |
# File 'app/models/dscf/marketplace/unit.rb', line 36 def display_name "#{name} (#{code})" end |