Module: Delayer::Priority::Extend

### Home Classes Methods

### In Files

- lib/delayer/priority.rb

### Methods

- ::extended
- #get_prev_point
- #register
- #validate_priority

### 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::Priority::Extend

### Public Class Methods

extended(klass) click to toggle source

    # File lib/delayer/priority.rb, line 20
    def self.extended(klass)
      klass.class_eval do
        @priority_pointer = {}
      end
    end

### Public Instance Methods

get_prev_point(priority) click to toggle source

    # File lib/delayer/priority.rb, line 52
    def get_prev_point(priority)
      if @priority_pointer[priority]
        @priority_pointer[priority]
      else
        next_index = @priorities.index(priority) - 1
        get_prev_point @priorities[next_index] if 0 <= next_index
      end
    end

register(procedure) click to toggle source

register new job.

#### Args

procedure

  job(Delayer::Procedure)

#### Return

self

    # File lib/delayer/priority.rb, line 31
    def register(procedure)
      priority = procedure.delayer.priority
      lock.synchronize do
        last_pointer = get_prev_point(priority)
        if last_pointer
          @priority_pointer[priority] = last_pointer.break procedure
        else
          procedure.next = @first_pointer
          @priority_pointer[priority] = @first_pointer = procedure
        end
        if @last_pointer
          @last_pointer = @priority_pointer[priority]
        end
        if @remain_hook and not @remain_received
          @remain_received = true
          @remain_hook.call
        end
      end
      self
    end

validate_priority(symbol) click to toggle source

    # File lib/delayer/priority.rb, line 61
    def validate_priority(symbol)
      unless @priorities.include? symbol
        raise Delayer::InvalidPriorityError, "undefined priority '#{symbol}'"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.