Sha256: 2a0c690fb1449d486fc271783c012ef233c9d38e555ddc3aa285439e42661e68

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Evostream
  module Events
    # Action OutStreamCreated
    class OutStreamCreated < Event
      def initialize(id_flux, request)
        super(id_flux)
        @request = request
      end

      def execute
        Evostream.logger "Update document (#{model.class}) in Database"
        stream_flux = what_flux.upcase.constantize
        model.streams.push(stream_flux.new(config_id: ex_config, flux: ex_flux))
        model.save
        @result = { status: 201, message: 'Action successfully executed.' }
      end

      private

      def what_flux
        hls? ? 'Hls' : 'Dash'
      end

      def hls?
        @request.key?(:hlsSettings) || @request.key?('hlsSettings')
      end

      def name_flux
        case what_flux
        when 'Hls' then 'playlistName'
        when 'Dash' then 'manifestName'
        end
      end

      def name_settings
        @request["#{what_flux.downcase}Settings"]
      end

      def ex_config
        name_settings['configId']
      end

      def ex_flux
        Evostream::Service.uri_out + '/' + name_settings['groupName'] + '/' +
          @request['name'] + '/' + name_settings[name_flux]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evostream-event-0.3.2.pre.56 lib/evostream/event/event/events/out_stream_created.rb
evostream-event-0.3.2.pre.55 lib/evostream/event/event/events/out_stream_created.rb
evostream-event-0.3.1 lib/evostream/event/event/events/out_stream_created.rb
evostream-event-0.3.1.pre.53 lib/evostream/event/event/events/out_stream_created.rb
evostream-event-0.3.1.pre.52 lib/evostream/event/event/events/out_stream_created.rb