Sha256: b30409544bd2959888fc3bb5c5b254e7e859726cd05a59689c829552407b2925

Contents?: true

Size: 603 Bytes

Versions: 29

Compression:

Stored size: 603 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
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
friendly_shipping-0.7.3 lib/friendly_shipping/package_options.rb
friendly_shipping-0.7.2 lib/friendly_shipping/package_options.rb
friendly_shipping-0.7.1 lib/friendly_shipping/package_options.rb
friendly_shipping-0.7.0 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.5 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.4 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.3 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.2 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.1 lib/friendly_shipping/package_options.rb
friendly_shipping-0.6.0 lib/friendly_shipping/package_options.rb
friendly_shipping-0.5.3 lib/friendly_shipping/package_options.rb
friendly_shipping-0.5.2 lib/friendly_shipping/package_options.rb
friendly_shipping-0.5.1 lib/friendly_shipping/package_options.rb
friendly_shipping-0.5 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.14 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.13 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.12 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.11 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.10 lib/friendly_shipping/package_options.rb
friendly_shipping-0.4.9 lib/friendly_shipping/package_options.rb