Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #131 from ramontayag/relax_hash_constraint

Relax hash constraint
  • Loading branch information...
commit 95da568a995ddc59d16744a866a2b1f01b0c7345 2 parents 8c2ff7c + 6a47551
@andi andi authored
View
8 lib/simple_navigation/core/item_adapter.rb
@@ -20,13 +20,13 @@ module SimpleNavigation
# See SimpleNavigation::ItemContainer#item for the purpose of these methods.
class ItemAdapter
extend Forwardable
-
+
def_delegators :item, :key, :name, :url
attr_reader :item
def initialize(item)
- @item = item.instance_of?(Hash) ? to_object(item) : item
+ @item = item.is_a?(Hash) ? to_object(item) : item
end
# Returns the options for this item. If the wrapped item does not implement an options method, an empty hash is returned.
@@ -45,7 +45,7 @@ def to_simple_navigation_item(item_container)
end
protected
-
+
# Converts the specified hash into an object. Each key will be added as method.
#
def to_object(hash)
@@ -60,4 +60,4 @@ def to_object(hash)
end
end
-end
+end
View
9 spec/lib/simple_navigation/core/item_adapter_spec.rb
@@ -101,10 +101,13 @@
end
-describe SimpleNavigation::ItemAdapter, 'when item is a hash' do
+describe SimpleNavigation::ItemAdapter, 'when item is a kind of hash' do
+
+ class ModifiedHash < Hash
+ end
before(:each) do
- @item = {:key => 'key', :url => 'url', :name => 'name'}
+ @item = ModifiedHash[:key => 'key', :url => 'url', :name => 'name']
@item_adapter = SimpleNavigation::ItemAdapter.new(@item)
end
@@ -206,4 +209,4 @@
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.