Skip to content

Commit

Permalink
Shorten adapter options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Nov 16, 2012
1 parent c681ab1 commit d4596d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/adapter/cassanity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Cassanity
# Public
def read(key, args = nil)
operation_options = {where: where(key)}
adapter_options = options[:read_options]
adapter_options = options[:read]
arguments = update_arguments(operation_options, adapter_options, args)

rows = client.select(arguments)
Expand All @@ -21,7 +21,7 @@ def read(key, args = nil)
# Public
def write(key, attributes, args = nil)
operation_options = {set: encode(attributes), where: where(key)}
adapter_options = options[:write_options]
adapter_options = options[:write]
arguments = update_arguments(operation_options, adapter_options, args)

client.update(arguments)
Expand All @@ -30,7 +30,7 @@ def write(key, attributes, args = nil)
# Public
def delete(key, args = nil)
operation_options = {where: where(key)}
adapter_options = options[:delete_options]
adapter_options = options[:delete]
arguments = update_arguments(operation_options, adapter_options, args)

client.delete(arguments)
Expand Down
18 changes: 9 additions & 9 deletions spec/cassanity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
context "with adapter read options" do
it "uses read options for read method" do
client = COLUMN_FAMILIES[:single]
options = {read_options: {
options = {read: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand All @@ -34,7 +34,7 @@

it "does not override where" do
client = COLUMN_FAMILIES[:single]
options = {read_options: {
options = {read: {
where: {:some_key => 'bar'},
using: {consistency: :quorum},
}}
Expand All @@ -50,7 +50,7 @@

it "can be overriden by read method options" do
client = COLUMN_FAMILIES[:single]
options = {read_options: {
options = {read: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand All @@ -67,7 +67,7 @@
context "with adapter write options" do
it "uses write options for write method" do
client = COLUMN_FAMILIES[:single]
options = {write_options: {
options = {write: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand All @@ -83,7 +83,7 @@

it "does not override where or set" do
client = COLUMN_FAMILIES[:single]
options = {write_options: {
options = {write: {
where: {:some_key => 'should not use this'},
set: {'name' => 'should not use this'},
using: {consistency: :quorum,
Expand All @@ -101,7 +101,7 @@

it "can be overriden by write method options" do
client = COLUMN_FAMILIES[:single]
options = {write_options: {
options = {write: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand All @@ -119,7 +119,7 @@
context "with adapter delete options" do
it "uses delete options for delete method" do
client = COLUMN_FAMILIES[:single]
options = {delete_options: {
options = {delete: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand All @@ -134,7 +134,7 @@

it "does not override where" do
client = COLUMN_FAMILIES[:single]
options = {delete_options: {
options = {delete: {
where: {:some_key => 'bar'},
using: {consistency: :quorum},
}}
Expand All @@ -150,7 +150,7 @@

it "can be overriden by delete method options" do
client = COLUMN_FAMILIES[:single]
options = {delete_options: {
options = {delete: {
using: {consistency: :quorum},
}}
adapter = Adapter[adapter_name].new(client, options)
Expand Down

0 comments on commit d4596d3

Please sign in to comment.