mattvperry / mumble-ruby

A headless mumble client API written in Ruby
MIT License
126 stars 34 forks source link

Calling user.inspect causes the bot to mute itself #51

Open nogweii opened 9 years ago

nogweii commented 9 years ago

I believe that it's because Mumble::User#mute actively mutes the person and you define mute as an attribute. Then, in Mumble::Model#inspect, you call each attribute as a method with send -- causing the bot to mute itself whenever inspect is called.

Inspect should probably just iterate through @data and do nothing else, since any of the attribute methods might have side effects.

nogweii commented 9 years ago

As a work around, this monkey patch works to avoid the problem:

module Mumble
  class Model
    def inspect
      rs = @data.map{|a, v| "#{a}=#{v}"}.join(' ')
      %Q{#<#{self.class.name} #{rs}>}
    end
  end
end