Module: Backgrounded::Model::ClassMethods

Defined in:
lib/backgrounded.rb

Instance Method Summary collapse

Instance Method Details

#backgrounded(*methods) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/backgrounded.rb', line 17

def backgrounded(*methods)
  methods.each do |method|
    method_basename, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
    define_method :"#{method_basename}_backgrounded#{punctuation}" do |*args|
      Backgrounded.handler.request(self, method, *args)
    end
  end
  include Backgrounded::Model::InstanceMethods
  extend Backgrounded::Model::SingletonMethods
end