Sha256: 39e84cc2537dd001f8de6f929990fc950845484ebb117f311154873194b739f1
Contents?: true
Size: 713 Bytes
Versions: 2
Compression:
Stored size: 713 Bytes
Contents
# frozen_string_literal: true module FriendlyShipping class PackageOptions attr_reader :package_id def initialize( package_id:, item_options: Set.new, item_options_class: ItemOptions ) @package_id = package_id @item_options = item_options @item_options_class = item_options_class end def options_for_item(item) item_options.detect do |item_option| item_option.item_id == item.id end || item_options_class.new(item_id: nil) end private attr_reader :item_options, :item_options_class def value_or_default(key, default, kwargs) kwargs.key?(key) ? kwargs.delete(key) : default end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.8.1 | lib/friendly_shipping/package_options.rb |
friendly_shipping-0.8.0 | lib/friendly_shipping/package_options.rb |