class IDRegistry::PatternAdder

This is the DSL available within the block passed to IDRegistry::Configuration#add_pattern.

Public Instance Methods

pattern(value_=nil) click to toggle source

Set the pattern to add

# File lib/idregistry/configuration.rb, line 451
def pattern(value_=nil)
  if value_
    @pattern = value_
  else
    @pattern
  end
end
to_generate_object(&block_) click to toggle source

Provide a block to call to generate the appropriate object given a tuple. This block is called when the repository is asked to lookup an object given a tuple, and the provided tuple is not yet present.

The block may take up to three arguments. The first is the tuple. The second is the repository containing the object. The third is a hash of arguments passed to the repository’s lookup method.

The block should return the generated object, or nil if it is unable to generate an object for the given tuple.

# File lib/idregistry/configuration.rb, line 484
def to_generate_object(&block_)
  if block_
    @gen_obj = block_
  else
    @gen_obj
  end
end
to_generate_tuple(&block_) click to toggle source

Provide a block to call to generate the tuple corresponding to an object. The repository calls this block when an object is added, in order to generate the appropriate tuples for looking up the object.

# File lib/idregistry/configuration.rb, line 497
def to_generate_tuple(&block_)
  if block_
    @gen_tuple = block_
  else
    @gen_tuple
  end
end
type(value_=nil) click to toggle source

Set the object type

# File lib/idregistry/configuration.rb, line 462
def type(value_=nil)
  if value_
    @type = value_
  else
    @type
  end
end