Module: Skr::Concerns::Sku::Locations
- Defined in:
- lib/skr/concerns/sku_extensions.rb
Instance Method Summary collapse
- #default ⇒ Object
-
#find_or_create_for(location) ⇒ Object
Attempt to find a SkuLoc record and create it if not found.
- #for_location(location) ⇒ Object
Instance Method Details
#default ⇒ Object
18 19 20 21 |
# File 'lib/skr/concerns/sku_extensions.rb', line 18 def default loc_id = Location.default.id detect{ |sl| sl.location_id == loc_id } end |
#find_or_create_for(location) ⇒ Object
Attempt to find a SkuLoc record and create it if not found
8 9 10 11 |
# File 'lib/skr/concerns/sku_extensions.rb', line 8 def find_or_create_for( location ) location_id = location.is_a?(Numeric) ? location : location.id for_location(location) || create!({ :location_id=>location_id }) end |
#for_location(location) ⇒ Object
13 14 15 16 |
# File 'lib/skr/concerns/sku_extensions.rb', line 13 def for_location( location ) location_id = location.is_a?(Numeric) ? location : location.id detect{ |l| l.location_id==location_id } end |