Permalink
Browse files

Explicit > method missing for options hash

  • Loading branch information...
jnunemaker committed Oct 11, 2012
1 parent 33c016f commit 2de7de3bc31c99236d70a31477e66652988ae89d
Showing with 9 additions and 13 deletions.
  1. +9 −5 lib/plucky/options_hash.rb
  2. +0 −8 spec/plucky/options_hash_spec.rb
View
@@ -17,16 +17,24 @@ def initialize(hash={}, options={})
def initialize_copy(source)
super
@source = @source.dup
- each do |key, value|
+ @source.each do |key, value|
self[key] = value.clone if value.duplicable?
end
end
+ def [](key)
+ @source[key]
+ end
+
def []=(key, value)
key = normalized_key(key)
source[key] = normalized_value(key, value)
end
+ def keys
+ @source.keys
+ end
+
def ==(other)
source == other.source
end
@@ -73,9 +81,5 @@ def value_normalizer
})
}
end
-
- def method_missing(method, *args, &block)
- @source.send(method, *args, &block)
- end
end
end
@@ -1,14 +1,6 @@
require 'helper'
describe Plucky::OptionsHash do
- it "delegates missing methods to the source hash" do
- hash = {:limit => 1, :skip => 1}
- options = described_class.new(hash)
- options[:skip].should == 1
- options[:limit].should == 1
- options.keys.to_set.should == [:limit, :skip].to_set
- end
-
describe "#initialize_copy" do
before do
@original = described_class.new(:fields => {:name => true}, :sort => :name, :limit => 10)

0 comments on commit 2de7de3

Please sign in to comment.