diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-02-06 11:05:38 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-02-06 11:51:13 -0700 |
commit | 101c19f55f5f1d86d35574b805278f11e9a1a48e (patch) | |
tree | cf5821f06acafe416a0cea205967f243f08ec9ef /activerecord/test/cases/attribute_decorators_test.rb | |
parent | d7318599160dbc6d362793673e8c6db926eeb7b8 (diff) | |
download | rails-101c19f55f5f1d86d35574b805278f11e9a1a48e.tar.gz rails-101c19f55f5f1d86d35574b805278f11e9a1a48e.tar.bz2 rails-101c19f55f5f1d86d35574b805278f11e9a1a48e.zip |
Allow a symbol to be passed to `attribute`, in place of a type object
The same is not true of `define_attribute`, which is meant to be the low
level no-magic API that sits underneath. The differences between the two
APIs are:
- `attribute`
- Lazy (the attribute will be defined after the schema has loaded)
- Allows either a type object or a symbol
- `define_attribute`
- Runs immediately (might get trampled by schema loading)
- Requires a type object
This was the last blocker in terms of public interface requirements
originally discussed for this feature back in May. All the
implementation blockers have been cleared, so this feature is probably
ready for release (pending one more look-over by me).
Diffstat (limited to 'activerecord/test/cases/attribute_decorators_test.rb')
-rw-r--r-- | activerecord/test/cases/attribute_decorators_test.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/test/cases/attribute_decorators_test.rb b/activerecord/test/cases/attribute_decorators_test.rb index 9ad02ffae8..0b96319cbd 100644 --- a/activerecord/test/cases/attribute_decorators_test.rb +++ b/activerecord/test/cases/attribute_decorators_test.rb @@ -51,7 +51,7 @@ module ActiveRecord end test "undecorated columns are not touched" do - Model.attribute :another_string, Type::String.new, default: 'something or other' + Model.attribute :another_string, :string, default: 'something or other' Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } assert_equal 'something or other', Model.new.another_string @@ -86,7 +86,7 @@ module ActiveRecord end test "decorating attributes does not modify parent classes" do - Model.attribute :another_string, Type::String.new, default: 'whatever' + Model.attribute :another_string, :string, default: 'whatever' Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } child_class = Class.new(Model) child_class.decorate_attribute_type(:another_string, :test) { |t| StringDecorator.new(t) } @@ -110,7 +110,7 @@ module ActiveRecord end test "decorating with a proc" do - Model.attribute :an_int, Type::Integer.new + Model.attribute :an_int, :integer type_is_integer = proc { |_, type| type.type == :integer } Model.decorate_matching_attribute_types type_is_integer, :multiplier do |type| Multiplier.new(type) |