Module: TransmissionRSS::Callback

Included in:
Aggregator, Config
Defined in:
lib/transmission-rss/callback.rb

Instance Method Summary collapse

Instance Method Details

#callback(*names) ⇒ Object

Define callback method.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/transmission-rss/callback.rb', line 4

def callback(*names)
  names.each do |name|
    self.class_eval do
      define_method name, ->(*args, &block) do
        @callbacks ||= {}
        if block
          @callbacks[name] = block
        elsif @callbacks[name]
          @callbacks[name].call(*args)
        end
      end
    end
  end
end