Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow changing attribute_type option for lists.

  • Loading branch information...
commit a5b1a944622509c32688d2e56088a7d7aa6fc0b3 1 parent 31c85e6
John Nunemaker authored
Showing with 13 additions and 2 deletions.
  1. +1 −1  lib/toy/list.rb
  2. +12 −1 spec/toy/list_spec.rb
2  lib/toy/list.rb
View
@@ -14,7 +14,7 @@ def initialize(model, name, *args, &block)
options[:extensions] = modularized_extensions(block, options[:extensions])
- model.attribute(key, Array)
+ model.attribute(key, options.fetch(:attribute_type) { Array })
create_accessors
end
13 spec/toy/list_spec.rb
View
@@ -498,6 +498,17 @@ def old
end
end
+ describe "list with :attribute_type option" do
+ before do
+ @type = stub
+ User.list :games, :attribute_type => @type
+ end
+
+ it "uses correct type" do
+ User.attributes['game_ids'].type.should eq(@type)
+ end
+ end
+
describe "list extension with :extensions option" do
before do
old_module = Module.new do
@@ -572,4 +583,4 @@ def recent
@user.games.get!(@game.id).should == @game
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.