Skip to content

Commit

Permalink
Added the ability to send options to the adapter instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Nov 12, 2010
1 parent ff2952f commit 82e8522
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/adapter.rb
Expand Up @@ -32,10 +32,11 @@ def self.[](name)
private
def self.get_adapter_instance(name)
Class.new do
attr_reader :client
attr_reader :client, :options

def initialize(client)
def initialize(client, options={})
@client = client
@options = options
end

include Adapter.definitions[name.to_sym]
Expand Down
8 changes: 8 additions & 0 deletions spec/adapter_spec.rb
Expand Up @@ -180,6 +180,14 @@ def decode(value)
end
let(:adapter) { @adapter }

describe "#initialize" do
it "works with options" do
Adapter.define(:memory, valid_module)
adapter = Adapter[:memory].new({}, :namespace => 'foo')
adapter.options[:namespace].should == 'foo'
end
end

describe "#name" do
it "returns adapter name" do
adapter.name.should be(:memory)
Expand Down

0 comments on commit 82e8522

Please sign in to comment.