Method: PM::DSL#message_key

Defined in:
lib/patchmaster/dsl.rb

#message_key(key_or_sym, name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/patchmaster/dsl.rb', line 62

def message_key(key_or_sym, name)
  if name.is_a?(Symbol)
      name, key_or_sym = key_or_sym, name
      $stderr.puts "WARNING: the arguments to message_key are now key first, then name."
      $stderr.puts "I will use #{name} as the name and #{key_or_sym} as the key for now."
      $stderr.puts "Please swap them for future compatability."
  end
  if key_or_sym.is_a?(String) && name.is_a?(String)
    if name.length == 1 && key_or_sym.length > 1
      name, key_or_sym = key_or_sym, name
      $stderr.puts "WARNING: the arguments to message_key are now key first, then name."
      $stderr.puts "I will use #{name} as the name and #{key_or_sym} as the key for now."
      $stderr.puts "Please swap them for future compatability."
    elsif name.length == 1 && key_or_sym.length == 1
      raise "message_key: since both name and key are one-character strings, I can't tell which is which. Please make the name longer."
    end
  end
  @pm.bind_message(name, to_binding_key(key_or_sym))
end