Class Module
In: lib/rbot/core/utils/extends.rb
Parent: Object
User HTTPResponse BasicUserMessage Bot\n[lib/rbot/core/remote.rb\nlib/rbot/core/utils/extends.rb\nlib/rbot/core/utils/filters.rb\nlib/rbot/core/utils/wordlist.rb] HttpUtil Array Module Numeric Range String\n[lib/rbot/botuser.rb\nlib/rbot/core/utils/extends.rb\nlib/rbot/irc.rb\nlib/rbot/ircsocket.rb\nlib/rbot/load-gettext.rb] Regexp\n[lib/rbot/core/utils/extends.rb\nlib/rbot/irc.rb\nlib/rbot/messagemapper.rb] lib/rbot/core/userdata.rb lib/rbot/core/utils/httputil.rb lib/rbot/core/utils/extends.rb lib/rbot/core/remote.rb lib/rbot/core/utils/httputil.rb ParseTime Utils (null) dot/f_13.png

Extensions to the Module class

Methods

Public Instance methods

Many plugins define Struct objects to hold their data. On rescans, lots of warnings are echoed because of the redefinitions. Using this method solves the problem, by checking if the Struct already exists, and if it has the same attributes

[Source]

    # File lib/rbot/core/utils/extends.rb, line 23
23:   def define_structure(name, *members)
24:     sym = name.to_sym
25:     if Struct.const_defined?(sym)
26:       kl = Struct.const_get(sym)
27:       if kl.new.members.map { |member| member.intern } == members.map
28:         debug "Struct #{sym} previously defined, skipping"
29:         const_set(sym, kl)
30:         return
31:       end
32:     end
33:     debug "Defining struct #{sym} with members #{members.inspect}"
34:     const_set(sym, Struct.new(name.to_s, *members))
35:   end

[Validate]