Class: IRC::Server::Module

Inherits:
Object show all
Defined in:
lib/failirc/server/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Module

Returns a new instance of Module.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/failirc/server/module.rb', line 29

def initialize (server)
    @server = server

    if @aliases
        if @aliases[:input]
            @aliases[:input].each {|key, value|
                @server.dispatcher.alias(:input, key, value)
            }
        end

        if @aliases[:output]
            @aliases[:output].each {|key, value|
                @server.dispatcher.alias(:output, key, value)
            }
        end
    end

    if @events
        if @events[:pre]
            @server.dispatcher.register(:pre, nil, @events[:pre])
        end

        if @events[:post]
            @server.dispatcher.register(:post, nil, @events[:post])
        end

        if @events[:default]
            @server.dispatcher.register(:default, nil, @events[:default])
        end
        
        if @events[:custom]
            @events[:custom].each {|key, value|
                @server.dispatcher.register(:custom, key, value)
            }
        end

        if @events[:input]
            @events[:input].each {|key, value|
                @server.dispatcher.register(:input, key, value)
            }
        end

        if @events[:output]
            @events[:output].each {|key, value|
                @server.dispatcher.register(:output, key, value)
            }
        end
    end

    begin
        rehash
    rescue NameError
    rescue Exception => e
        self.debug e
    end
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



27
28
29
# File 'lib/failirc/server/module.rb', line 27

def server
  @server
end

Instance Method Details

#finalizeObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/failirc/server/module.rb', line 86

def finalize
    if @aliases
        @aliases.each_key {|key|
            @server.dispatcher.alias(key, nil)
        }
    end

    if @events
        @events.each_key {|key|
            @server.dispatcher.register(key, nil)
        }
    end
end