Module: Delayer

### Home Classes Methods

### In Files

- lib/delayer.rb
- lib/delayer/error.rb
- lib/delayer/extend.rb
- lib/delayer/priority.rb
- lib/delayer/procedure.rb
- lib/delayer/version.rb

### Namespace

- MODULE Delayer::Extend
- MODULE Delayer::Priority
- CLASS Delayer::AlreadyCanceledError
- CLASS Delayer::AlreadyExecutedError
- CLASS Delayer::AlreadyRunningError
- CLASS Delayer::Error
- CLASS Delayer::InvalidPriorityError
- CLASS Delayer::Procedure
- CLASS Delayer::TooLate

### Methods

- ::StateError
- ::generate_class
- ::included
- ::method_missing
- ::new
- #cancel

### Included Modules

- Delayer::Priority
- Delayer

### Class/Module Index

Quicksearch

- Delayer
- Delayer::AlreadyCanceledError
- Delayer::AlreadyExecutedError
- Delayer::AlreadyRunningError
- Delayer::Error
- Delayer::Extend
- Delayer::InvalidPriorityError
- Delayer::Priority
- Delayer::Priority::Extend
- Delayer::Procedure
- Delayer::TooLate

No matching classes.

# Delayer

### Constants

VERSION

### Attributes

default[RW]

### Public Class Methods

StateError(state) click to toggle source

    # File lib/delayer/error.rb, line 9
    def self.StateError(state)
      case state
      when :run
        AlreadyRunningError
      when :done
        AlreadyExecutedError
      when :cancel
        AlreadyCanceledError
      end
    end

generate_class(options = {}) click to toggle source

Generate new Delayer class.

#### Args

options

  Hash

  expire | processing expire (secs, 0=unlimited)
  priority | priorities
  default | default priotity

#### Return

A new class

    # File lib/delayer.rb, line 25
    def generate_class(options = {})
      if options[:priority]
        Class.new do
          include Priority
          @expire = options[:expire] || 0
          @priorities = options[:priority]
          @default_priority = options[:default]
        end
      else
        Class.new do
          include ::Delayer
          @expire = options[:expire] || 0
        end
      end
    end

included(klass) click to toggle source

    # File lib/delayer.rb, line 12
    def included(klass)
      klass.extend Extend
    end

method_missing(*args, &proc) click to toggle source

    # File lib/delayer.rb, line 41
    def method_missing(*args, &proc)
      (@default ||= generate_class).__send__(*args, &proc)
    end

new(*args) click to toggle source

    # File lib/delayer.rb, line 46
    def initialize(*args)
      super
      @procedure = Procedure.new(self, &Proc.new)
    end

### Public Instance Methods

cancel() click to toggle source

Cancel this job

#### Exception

Delayer::AlreadyExecutedError | if already called run()

#### Return

self

    # File lib/delayer.rb, line 56
    def cancel
      @procedure.cancel
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.