You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: provisioning_profile.rb
    path of file: ./repos/fastlane/spaceship/lib/spaceship/portal
    
    the code of the file until where you have to start completion: require_relative 'app'
require_relative 'device'
require_relative 'certificate'
require_relative 'provisioning_profile_template'

module Spaceship
  module Portal
    # Represents a provisioning profile of the Apple Dev Portal
    #
    # NOTE: If the environment variable `SPACESHIP_AVOID_XCODE_API` is present when using this class, all requests will be made via Apple develope
    
        def factory(attrs)
          # available values of `distributionMethod` at this point: ['adhoc', 'store', 'limited', 'direct', 'inhouse']
          klass = case attrs['distributionMethod']
                  when 'limited'
                    Development
                  when 'store'
                    AppStore
                  when 'adhoc'
                    AdHoc
                  when 'inhouse'
                    InHouse
                  when 'direct'
                    Direct # Mac-only
                  else
                    raise "Can't find class '#{attrs['distributionMethod']}'"
                  end