virtus 1.0.0.beta3 → 1.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/virtus/extensions.rb +1 -1
- data/lib/virtus/version.rb +1 -1
- data/spec/unit/virtus/attribute_spec.rb +6 -0
- metadata +1 -1
data/lib/virtus/extensions.rb
CHANGED
@@ -63,7 +63,7 @@ module Virtus
|
|
63
63
|
# @see Attribute.build
|
64
64
|
#
|
65
65
|
# @api public
|
66
|
-
def attribute(name, type, options = {})
|
66
|
+
def attribute(name, type = Object, options = {})
|
67
67
|
assert_valid_name(name)
|
68
68
|
attribute_set << Attribute.build(type, merge_options(name, options))
|
69
69
|
self
|
data/lib/virtus/version.rb
CHANGED
@@ -56,6 +56,12 @@ describe Virtus, '#attribute' do
|
|
56
56
|
expect(klass.attribute_set[:attributes]).to be_instance_of(Virtus::Attribute::Collection)
|
57
57
|
end
|
58
58
|
|
59
|
+
it 'allows specifying attribute without type' do
|
60
|
+
klass = Class.new { include Virtus::Model::Core }
|
61
|
+
klass.attribute(:name)
|
62
|
+
expect(klass.attribute_set[:name]).to be_instance_of(Virtus::Attribute)
|
63
|
+
end
|
64
|
+
|
59
65
|
context 'with a class' do
|
60
66
|
context 'when type is Boolean' do
|
61
67
|
before :all do
|