Permalink
Browse files

Allow changing attribute_type option for lists.

  • Loading branch information...
1 parent 31c85e6 commit a5b1a944622509c32688d2e56088a7d7aa6fc0b3 @jnunemaker committed May 19, 2012
Showing with 13 additions and 2 deletions.
  1. +1 −1 lib/toy/list.rb
  2. +12 −1 spec/toy/list_spec.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
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

0 comments on commit a5b1a94

Please sign in to comment.