Sha256: 6783bf43a06aa24e2325dfb93bb28bb21485f193bb9a6fc287c7a6c40d235766

Contents?: true

Size: 403 Bytes

Versions: 2

Compression:

Stored size: 403 Bytes

Contents

module Stockman
  module Logic
    class SellableFactory
      VALID_SELLABLE_TYPES = ['variants', 'kits']

      def self.build_sellable(sellable_data)
        type, id = *sellable_data.split(":")

        raise "#{type} is not valid sellable type" unless VALID_SELLABLE_TYPES.include?(type)

        "Stockman::Logic::#{type.singularize.classify}".constantize.new(id.to_i)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stockman-logic-0.1.1 lib/stockman/logic/sellable_factory.rb
stockman-logic-0.1.0 lib/stockman/logic/sellable_factory.rb