lib/punchblock/command/join.rb in punchblock-1.7.1 vs lib/punchblock/command/join.rb in punchblock-1.8.0

- old
+ new

@@ -3,10 +3,12 @@ module Punchblock module Command class Join < CommandNode register :join, :core + VALID_DIRECTIONS = [:duplex, :send, :recv].freeze + ## # Create a join command # # @param [Hash] options # @option options [String, Optional] :call_id the call ID to join @@ -57,11 +59,14 @@ read_attr :direction, :to_sym end ## # @param [String] other the direction in which media should flow. Can be :duplex, :recv or :send - def direction=(other) - write_attr :direction, other + def direction=(direction) + if direction && !VALID_DIRECTIONS.include?(direction.to_sym) + raise ArgumentError, "Invalid Direction (#{direction}), use: #{VALID_DIRECTIONS*' '}" + end + write_attr :direction, direction end ## # @return [String] the method by which to negotiate media def media