Module: Rbdb::Util

Defined in:
lib/rbdb/util.rb

Class Method Summary collapse

Class Method Details

.check_existence_and_force(collection, name, options, &block) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
# File 'lib/rbdb/util.rb', line 4

def check_existence_and_force(collection, name, options, &block)
  raise ArgumentError, "method requires a block" unless block_given?
  if collection.include?(name) && !options[:force]
    raise 'Entity already exists. Use the force option to overwrite'
  else
    block.call
  end
end