class Rebar::DSL::Database

Attributes

connection[R]

Public Class Methods

new(connection) click to toggle source
# File lib/rebar/dsl/database.rb, line 4
def initialize(connection)
  @connection = connection
  @max_ids = ::Hash.new(0)
end

Public Instance Methods

hashes(count, &block) click to toggle source
# File lib/rebar/dsl/database.rb, line 17
def hashes(count, &block)
  count.times do
    Rebar::DSL::Hash.new(connection, "rebar:hash:#{next_id(:hash)}", &block)
  end
end
lists(count, &block) click to toggle source
# File lib/rebar/dsl/database.rb, line 23
def lists(count, &block)
  count.times do
    Rebar::DSL::List.new(connection, "rebar:list:#{next_id(:list)}", &block)
  end
end
sets(count, &block) click to toggle source
# File lib/rebar/dsl/database.rb, line 29
def sets(count, &block)
  count.times do
    Rebar::DSL::Set.new(connection, "rebar:set:#{next_id(:set)}", &block)
  end
end
sorted_sets(count, &block) click to toggle source
# File lib/rebar/dsl/database.rb, line 35
def sorted_sets(count, &block)
  count.times do
    Rebar::DSL::SortedSet.new(connection, "rebar:sorted_set:#{next_id(:sorted_set)}", &block)
  end
end
strings(count) click to toggle source
# File lib/rebar/dsl/database.rb, line 11
def strings(count)
  count.times do
    connection.set("rebar:string:#{next_id(:string)}", Rebar::Random.string)
  end
end

Private Instance Methods

next_id(type) click to toggle source
# File lib/rebar/dsl/database.rb, line 43
def next_id(type)
  @max_ids[type] += 1
end