Class: DataMapper::Sweatshop::UniqueWorker

### Home Classes Methods

### In Files

- lib/dm-sweatshop/unique.rb

### Parent

Object

### Methods

- ::key_for

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Model
- DataMapper::Sweatshop
- DataMapper::Sweatshop::ClassAttributes
- DataMapper::Sweatshop::NoFixtureExist
- DataMapper::Sweatshop::Unique
- DataMapper::Sweatshop::Unique::TooManyTriesException
- DataMapper::Sweatshop::UniqueWorker

No matching classes.

# DataMapper::Sweatshop::UniqueWorker

### Constants

MAX_TRIES

### Public Class Methods

key_for(&block) click to toggle source

Use the sexp representation of the block as a unique key for the block If you copy and paste a block, it will still have the same key

return <Object> the unique key for the block

    # File lib/dm-sweatshop/unique.rb, line 78
    def self.key_for(&block)
      raise "You need to install ParseTree to use anonymous an anonymous unique (gem install ParseTree). In the mean time, explicitly declare a key: unique(:my_key) { ... }" unless Object::const_defined?("ParseTree")

      klass = Class.new
      name = "tmp"
      klass.send(:define_method, name, &block)
      self.parser ||= ParseTree.new(false)
      self.parser.parse_tree_for_method(klass, name).last
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.