Sha256: 37013b12805f7f0ee330a8ca1289bcff185f9b6e579089b90e2d57fdbe3ce849

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

require 'activesupport'

module Backgrounded
  mattr_accessor :handler
  def self.handler
    @@handler ||= Backgrounded::Handler::InprocessHandler.new
  end
  
  autoload :Handler, 'handler'
        
  module Model
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      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
    end

    module SingletonMethods
    end

    module InstanceMethods
    end
  end
end

Object.send(:include, Backgrounded::Model)

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
wireframe-backgrounded-0.3.0 lib/backgrounded.rb
backgrounded-0.3.1 lib/backgrounded.rb