Skip to content

Commit

Permalink
Update table to table_name
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzz committed Jan 31, 2014
1 parent 96a98ec commit 187fc9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/moe/dyna.rb
Expand Up @@ -17,7 +17,7 @@ def batch_write_item(write_tables, items)
end
end

def create(name, copies=1, hash_key="hash", range_key=nil, read_capacity=5, write_capacity=10)
def create_table(name, copies=1, hash_key="hash", range_key=nil, read_capacity=5, write_capacity=10)
[].tap do |tables|
1.upto(copies).each do |copy|
schema = table_schema "#{name}_#{copy}",
Expand Down
4 changes: 2 additions & 2 deletions lib/moe/table_manager.rb
Expand Up @@ -6,11 +6,11 @@ class TableManager
def initialize
@date = Time.now.strftime("%F")
@dyna = Dyna.new
@meta = dyna.find(meta_table_names.first) || dyna.create(meta_table_name, 2)
@meta = dyna.find(meta_table_names.first) || dyna.create_table(meta_table_name, 2)
end

def build(model, copies=1, hash_key="hash", range_key=nil, read_capacity=5, write_capacity=10, read_tables=[])
write_tables = dyna.create table_name(model),
write_tables = dyna.create_table table_name(model),
copies,
hash_key,
range_key,
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/dyna_spec.rb
Expand Up @@ -8,7 +8,7 @@
let(:dynamodb) { Aws.dynamodb }
let(:item) { { "hash" => "test#{count}" } }
let(:dynamo_item) { dyna.explode(item) }
let(:created_tables) { dyna.create("Testy#{count}") }
let(:created_tables) { dyna.create_table("Testy#{count}") }
let(:table) { dyna.find(created_tables.first).table }

describe "#batch_write_item" do
Expand All @@ -21,17 +21,17 @@
end
end

describe "#create" do
describe "#create_table" do
it "creates a new table" do
new_table = dyna.create "Testy#{count}"
new_table = dyna.create_table "Testy#{count}"

expect(
dynamodb.list_tables.table_names.include? "Testy#{count}_1"
).to be_true
end

it "creates as many copies of a table as requested" do
new_tables = dyna.create "Testie#{count}", 5
new_tables = dyna.create_table "Testie#{count}", 5

expect(
dynamodb.list_tables.table_names.include? "Testie#{count}_1"
Expand Down Expand Up @@ -61,7 +61,7 @@

it "gets an item across multiple tables" do
dynamodb.put_item table_name: table.table_name, item: dynamo_item
empty_table = dyna.create "Testy#{count}_empty"
empty_table = dyna.create_table "Testy#{count}_empty"
result = dyna.get_item [table.table_name, "Testy#{count}_empty_1"], dynamo_item

expect( result["hash"]["s"] ).to eq("test#{count}")
Expand All @@ -78,7 +78,7 @@

describe "#find" do
it "finds a table" do
dyna.create "Testy#{count}"
dyna.create_table "Testy#{count}"

expect(
dyna.find("Testy#{count}_1").table.table_name
Expand All @@ -102,7 +102,7 @@
end

it "puts an item to multiple tables" do
mirror_tables = dyna.create "Testie#{count}", 2
mirror_tables = dyna.create_table "Testie#{count}", 2
dyna.put_item ["Testie#{count}_1", "Testie#{count}_2"], item

expect(
Expand Down

0 comments on commit 187fc9c

Please sign in to comment.