Sha256: 85abc7e876c3ee09fddcca5df61edc7d0d7b83a84dfe667ace6bfb84ec43dac6

Contents?: true

Size: 624 Bytes

Versions: 10

Compression:

Stored size: 624 Bytes

Contents

# frozen_string_literal: true

module Evostream
  # Send an action to evostream server
  class Action
    def initialize(payload = {})
      @payload = payload
    end

    def execute_action(command_name)
      cmd = command_name.sub(/^(\w)/, &:capitalize)
      klass = get_class(cmd)

      Evostream.logger "Execute action with cmd : #{klass}"
      Evostream.send_command(klass.new(@payload).cmd)
    end

    private

    def get_class(cmd)
      "Evostream::Commands::#{cmd}".constantize
    rescue
      message = "Command [#{cmd}] dosen't exist."
      puts message
      Evostream.logger message
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
evostream-event-1.0.1 lib/evostream/action/action.rb
evostream-event-1.0.1.pre.72 lib/evostream/action/action.rb
evostream-event-1.0.0 lib/evostream/action/action.rb
evostream-event-1.0.0.pre.69 lib/evostream/action/action.rb
evostream-event-1.0.0.pre.65 lib/evostream/action/action.rb
evostream-event-1.0.0.pre.59 lib/evostream/action/action.rb
evostream-event-1.0.0.pre.58 lib/evostream/event/action.rb
evostream-event-0.3.2.pre.57 lib/evostream/event/action.rb
evostream-event-0.3.2.pre.56 lib/evostream/event/action.rb
evostream-event-0.3.2.pre.55 lib/evostream/event/action.rb