virtus 0.5.5 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -8
- data/Gemfile +8 -2
- data/Gemfile.devtools +24 -30
- data/Guardfile +17 -6
- data/README.md +215 -77
- data/TODO.md +6 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/mutant.yml +12 -1
- data/config/reek.yml +57 -66
- data/lib/virtus.rb +126 -42
- data/lib/virtus/attribute.rb +52 -240
- data/lib/virtus/attribute/accessor.rb +91 -0
- data/lib/virtus/attribute/boolean.rb +11 -8
- data/lib/virtus/attribute/builder.rb +120 -0
- data/lib/virtus/attribute/coercer.rb +51 -0
- data/lib/virtus/attribute/coercible.rb +14 -0
- data/lib/virtus/attribute/collection.rb +44 -90
- data/lib/virtus/attribute/default_value/from_callable.rb +1 -1
- data/lib/virtus/attribute/default_value/from_clonable.rb +1 -6
- data/lib/virtus/attribute/default_value/from_symbol.rb +3 -3
- data/lib/virtus/attribute/embedded_value.rb +37 -28
- data/lib/virtus/attribute/hash.rb +69 -71
- data/lib/virtus/attribute/lazy_default.rb +18 -0
- data/lib/virtus/attribute/strict.rb +16 -0
- data/lib/virtus/attribute_set.rb +81 -9
- data/lib/virtus/class_inclusions.rb +24 -17
- data/lib/virtus/class_methods.rb +13 -31
- data/lib/virtus/configuration.rb +77 -0
- data/lib/virtus/const_missing_extensions.rb +16 -0
- data/lib/virtus/extensions.rb +86 -61
- data/lib/virtus/instance_methods.rb +107 -128
- data/lib/virtus/model.rb +68 -0
- data/lib/virtus/module_builder.rb +184 -0
- data/lib/virtus/module_extensions.rb +27 -15
- data/lib/virtus/support/equalizer.rb +2 -3
- data/lib/virtus/support/type_lookup.rb +1 -1
- data/lib/virtus/value_object.rb +24 -31
- data/lib/virtus/version.rb +1 -1
- data/spec/integration/building_module_spec.rb +68 -0
- data/spec/integration/custom_attributes_spec.rb +8 -15
- data/spec/integration/custom_collection_attributes_spec.rb +101 -0
- data/spec/integration/default_values_spec.rb +9 -2
- data/spec/integration/defining_attributes_spec.rb +2 -2
- data/spec/integration/using_modules_spec.rb +5 -3
- data/spec/shared/freeze_method_behavior.rb +2 -2
- data/spec/shared/options_class_method.rb +1 -1
- data/spec/spec_helper.rb +25 -5
- data/spec/unit/virtus/attribute/boolean/value_coerced_predicate_spec.rb +25 -0
- data/spec/unit/virtus/attribute/class_methods/build_spec.rb +115 -22
- data/spec/unit/virtus/attribute/class_methods/coerce_spec.rb +32 -0
- data/spec/unit/virtus/attribute/coerce_spec.rb +38 -21
- data/spec/unit/virtus/attribute/coercible_predicate_spec.rb +20 -0
- data/spec/unit/virtus/attribute/collection/class_methods/build_spec.rb +84 -0
- data/spec/unit/virtus/attribute/collection/coerce_spec.rb +37 -24
- data/spec/unit/virtus/attribute/custom_collection_spec.rb +23 -0
- data/spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb +37 -0
- data/spec/unit/virtus/attribute/embedded_value/coerce_spec.rb +46 -10
- data/spec/unit/virtus/attribute/get_spec.rb +15 -63
- data/spec/unit/virtus/attribute/hash/class_methods/build_spec.rb +80 -0
- data/spec/unit/virtus/attribute/hash/coerce_spec.rb +75 -13
- data/spec/unit/virtus/attribute/lazy_predicate_spec.rb +20 -0
- data/spec/unit/virtus/attribute/set_default_value_spec.rb +74 -0
- data/spec/unit/virtus/attribute/set_spec.rb +16 -36
- data/spec/unit/virtus/attribute/value_coerced_predicate_spec.rb +19 -0
- data/spec/unit/virtus/attribute_set/append_spec.rb +3 -5
- data/spec/unit/virtus/attribute_set/define_reader_method_spec.rb +1 -1
- data/spec/unit/virtus/attribute_set/define_writer_method_spec.rb +1 -1
- data/spec/unit/virtus/attribute_set/each_spec.rb +3 -3
- data/spec/unit/virtus/attribute_set/element_reference_spec.rb +1 -1
- data/spec/unit/virtus/attribute_set/element_set_spec.rb +4 -4
- data/spec/unit/virtus/attribute_set/merge_spec.rb +10 -16
- data/spec/unit/virtus/attribute_set/reset_spec.rb +6 -10
- data/spec/unit/virtus/attribute_spec.rb +222 -0
- data/spec/unit/virtus/attributes_reader_spec.rb +41 -0
- data/spec/unit/virtus/attributes_writer_spec.rb +51 -0
- data/spec/unit/virtus/class_methods/new_spec.rb +39 -0
- data/spec/unit/virtus/config_spec.rb +13 -0
- data/spec/unit/virtus/element_reader_spec.rb +21 -0
- data/spec/unit/virtus/element_writer_spec.rb +19 -0
- data/spec/unit/virtus/freeze_spec.rb +21 -0
- data/spec/unit/virtus/model_spec.rb +134 -0
- data/spec/unit/virtus/module_spec.rb +76 -0
- data/spec/unit/virtus/set_default_attributes_spec.rb +25 -0
- data/spec/unit/virtus/value_object_spec.rb +105 -0
- data/virtus.gemspec +4 -2
- metadata +82 -191
- data/.rvmrc +0 -1
- data/TODO +0 -1
- data/config/roodi.yml +0 -17
- data/lib/virtus/attribute/array.rb +0 -24
- data/lib/virtus/attribute/class.rb +0 -21
- data/lib/virtus/attribute/date.rb +0 -34
- data/lib/virtus/attribute/date_time.rb +0 -36
- data/lib/virtus/attribute/decimal.rb +0 -21
- data/lib/virtus/attribute/embedded_value/from_open_struct.rb +0 -19
- data/lib/virtus/attribute/embedded_value/from_struct.rb +0 -19
- data/lib/virtus/attribute/float.rb +0 -30
- data/lib/virtus/attribute/integer.rb +0 -27
- data/lib/virtus/attribute/numeric.rb +0 -11
- data/lib/virtus/attribute/object.rb +0 -11
- data/lib/virtus/attribute/set.rb +0 -24
- data/lib/virtus/attribute/string.rb +0 -24
- data/lib/virtus/attribute/symbol.rb +0 -21
- data/lib/virtus/attribute/time.rb +0 -36
- data/lib/virtus/coercion.rb +0 -32
- data/lib/virtus/coercion/array.rb +0 -23
- data/lib/virtus/coercion/date.rb +0 -26
- data/lib/virtus/coercion/date_time.rb +0 -26
- data/lib/virtus/coercion/decimal.rb +0 -40
- data/lib/virtus/coercion/false_class.rb +0 -24
- data/lib/virtus/coercion/float.rb +0 -39
- data/lib/virtus/coercion/hash.rb +0 -71
- data/lib/virtus/coercion/integer.rb +0 -83
- data/lib/virtus/coercion/numeric.rb +0 -66
- data/lib/virtus/coercion/object.rb +0 -125
- data/lib/virtus/coercion/string.rb +0 -218
- data/lib/virtus/coercion/symbol.rb +0 -24
- data/lib/virtus/coercion/time.rb +0 -40
- data/lib/virtus/coercion/time_coercions.rb +0 -86
- data/lib/virtus/coercion/true_class.rb +0 -24
- data/spec/unit/virtus/attribute/array/coerce_spec.rb +0 -13
- data/spec/unit/virtus/attribute/boolean/coerce_spec.rb +0 -85
- data/spec/unit/virtus/attribute/boolean/define_reader_method_spec.rb +0 -15
- data/spec/unit/virtus/attribute/boolean/value_coerced_spec.rb +0 -97
- data/spec/unit/virtus/attribute/boolean_spec.rb +0 -19
- data/spec/unit/virtus/attribute/class/coerce_spec.rb +0 -13
- data/spec/unit/virtus/attribute/class_methods/accessor_spec.rb +0 -12
- data/spec/unit/virtus/attribute/class_methods/coercion_method_spec.rb +0 -9
- data/spec/unit/virtus/attribute/class_methods/default_spec.rb +0 -9
- data/spec/unit/virtus/attribute/class_methods/determine_type_spec.rb +0 -117
- data/spec/unit/virtus/attribute/class_methods/merge_options_spec.rb +0 -11
- data/spec/unit/virtus/attribute/class_methods/primitive_spec.rb +0 -9
- data/spec/unit/virtus/attribute/class_methods/reader_spec.rb +0 -9
- data/spec/unit/virtus/attribute/class_methods/writer_spec.rb +0 -9
- data/spec/unit/virtus/attribute/coercion_method_spec.rb +0 -12
- data/spec/unit/virtus/attribute/collection/class_methods/merge_options_spec.rb +0 -40
- data/spec/unit/virtus/attribute/collection/coerce_and_append_member_spec.rb +0 -16
- data/spec/unit/virtus/attribute/collection/member_coercion/coerce_and_append_member_spec.rb +0 -18
- data/spec/unit/virtus/attribute/collection/member_type_spec.rb +0 -17
- data/spec/unit/virtus/attribute/collection/new_collection_spec.rb +0 -9
- data/spec/unit/virtus/attribute/date/coerce_spec.rb +0 -47
- data/spec/unit/virtus/attribute/date/value_coerced_spec.rb +0 -46
- data/spec/unit/virtus/attribute/date_time/coerce_spec.rb +0 -80
- data/spec/unit/virtus/attribute/decimal/coerce_spec.rb +0 -123
- data/spec/unit/virtus/attribute/default_spec.rb +0 -28
- data/spec/unit/virtus/attribute/default_value/call_spec.rb +0 -21
- data/spec/unit/virtus/attribute/default_value/class_methods/build_spec.rb +0 -23
- data/spec/unit/virtus/attribute/default_value/class_methods/new_spec.rb +0 -21
- data/spec/unit/virtus/attribute/default_value/from_callable/call_spec.rb +0 -19
- data/spec/unit/virtus/attribute/default_value/from_callable/class_methods/handle_spec.rb +0 -17
- data/spec/unit/virtus/attribute/default_value/from_clonable/call_spec.rb +0 -20
- data/spec/unit/virtus/attribute/default_value/from_clonable/class_methods/handle_spec.rb +0 -19
- data/spec/unit/virtus/attribute/default_value/from_symbol/call_spec.rb +0 -17
- data/spec/unit/virtus/attribute/default_value/from_symbol/class_methods/handle_spec.rb +0 -17
- data/spec/unit/virtus/attribute/default_value/value_spec.rb +0 -10
- data/spec/unit/virtus/attribute/define_accessor_methods_spec.rb +0 -26
- data/spec/unit/virtus/attribute/define_reader_method_spec.rb +0 -24
- data/spec/unit/virtus/attribute/define_writer_method_spec.rb +0 -24
- data/spec/unit/virtus/attribute/embedded_value/class_methods/determine_type_spec.rb +0 -23
- data/spec/unit/virtus/attribute/embedded_value/class_methods/merge_options_spec.rb +0 -17
- data/spec/unit/virtus/attribute/embedded_value/from_open_struct/coerce_spec.rb +0 -34
- data/spec/unit/virtus/attribute/embedded_value/from_struct/coerce_spec.rb +0 -34
- data/spec/unit/virtus/attribute/float/coerce_spec.rb +0 -123
- data/spec/unit/virtus/attribute/hash/class_methods/merge_options_spec.rb +0 -33
- data/spec/unit/virtus/attribute/hash/key_type_spec.rb +0 -10
- data/spec/unit/virtus/attribute/hash/value_type_spec.rb +0 -10
- data/spec/unit/virtus/attribute/inspect_spec.rb +0 -27
- data/spec/unit/virtus/attribute/integer/coerce_spec.rb +0 -117
- data/spec/unit/virtus/attribute/name_spec.rb +0 -12
- data/spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb +0 -15
- data/spec/unit/virtus/attribute/numeric/class_methods/max_spec.rb +0 -9
- data/spec/unit/virtus/attribute/numeric/class_methods/min_spec.rb +0 -9
- data/spec/unit/virtus/attribute/options_spec.rb +0 -14
- data/spec/unit/virtus/attribute/public_reader_spec.rb +0 -24
- data/spec/unit/virtus/attribute/public_writer_spec.rb +0 -24
- data/spec/unit/virtus/attribute/set/coerce_spec.rb +0 -13
- data/spec/unit/virtus/attribute/string/coerce_spec.rb +0 -11
- data/spec/unit/virtus/attribute/symbol/coerce_spec.rb +0 -13
- data/spec/unit/virtus/attribute/time/coerce_spec.rb +0 -67
- data/spec/unit/virtus/attribute/value_coerced_spec.rb +0 -19
- data/spec/unit/virtus/class_methods/attribute_set_spec.rb +0 -9
- data/spec/unit/virtus/class_methods/attribute_spec.rb +0 -30
- data/spec/unit/virtus/class_methods/attributes_spec.rb +0 -22
- data/spec/unit/virtus/class_methods/const_missing_spec.rb +0 -27
- data/spec/unit/virtus/class_methods/inherited_spec.rb +0 -21
- data/spec/unit/virtus/coercion/array/class_methods/to_set_spec.rb +0 -12
- data/spec/unit/virtus/coercion/class_methods/element_reference_spec.rb +0 -17
- data/spec/unit/virtus/coercion/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/virtus/coercion/date/class_methods/to_date_spec.rb +0 -10
- data/spec/unit/virtus/coercion/date/class_methods/to_datetime_spec.rb +0 -30
- data/spec/unit/virtus/coercion/date/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/date/class_methods/to_time_spec.rb +0 -12
- data/spec/unit/virtus/coercion/date_time/class_methods/to_date_spec.rb +0 -30
- data/spec/unit/virtus/coercion/date_time/class_methods/to_datetime_spec.rb +0 -10
- data/spec/unit/virtus/coercion/date_time/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/date_time/class_methods/to_time_spec.rb +0 -30
- data/spec/unit/virtus/coercion/decimal/class_methods/to_decimal_spec.rb +0 -9
- data/spec/unit/virtus/coercion/decimal/class_methods/to_float_spec.rb +0 -12
- data/spec/unit/virtus/coercion/decimal/class_methods/to_integer_spec.rb +0 -12
- data/spec/unit/virtus/coercion/decimal/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/false_class/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/float/class_methods/to_decimal_spec.rb +0 -12
- data/spec/unit/virtus/coercion/float/class_methods/to_float_spec.rb +0 -9
- data/spec/unit/virtus/coercion/float/class_methods/to_integer_spec.rb +0 -12
- data/spec/unit/virtus/coercion/float/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/hash/class_methods/to_date_spec.rb +0 -38
- data/spec/unit/virtus/coercion/hash/class_methods/to_datetime_spec.rb +0 -38
- data/spec/unit/virtus/coercion/hash/class_methods/to_time_spec.rb +0 -38
- data/spec/unit/virtus/coercion/integer/class_methods/to_boolean_spec.rb +0 -25
- data/spec/unit/virtus/coercion/integer/class_methods/to_decimal_spec.rb +0 -12
- data/spec/unit/virtus/coercion/integer/class_methods/to_float_spec.rb +0 -12
- data/spec/unit/virtus/coercion/integer/class_methods/to_integer_spec.rb +0 -9
- data/spec/unit/virtus/coercion/integer/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/numeric/class_methods/to_decimal_spec.rb +0 -10
- data/spec/unit/virtus/coercion/numeric/class_methods/to_float_spec.rb +0 -10
- data/spec/unit/virtus/coercion/numeric/class_methods/to_integer_spec.rb +0 -10
- data/spec/unit/virtus/coercion/numeric/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb +0 -33
- data/spec/unit/virtus/coercion/object/class_methods/to_array_spec.rb +0 -51
- data/spec/unit/virtus/coercion/object/class_methods/to_hash_spec.rb +0 -22
- data/spec/unit/virtus/coercion/object/class_methods/to_integer_spec.rb +0 -22
- data/spec/unit/virtus/coercion/object/class_methods/to_string_spec.rb +0 -22
- data/spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb +0 -29
- data/spec/unit/virtus/coercion/string/class_methods/to_constant_spec.rb +0 -49
- data/spec/unit/virtus/coercion/string/class_methods/to_date_spec.rb +0 -23
- data/spec/unit/virtus/coercion/string/class_methods/to_datetime_spec.rb +0 -50
- data/spec/unit/virtus/coercion/string/class_methods/to_decimal_spec.rb +0 -47
- data/spec/unit/virtus/coercion/string/class_methods/to_float_spec.rb +0 -57
- data/spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb +0 -68
- data/spec/unit/virtus/coercion/string/class_methods/to_symbol_spec.rb +0 -9
- data/spec/unit/virtus/coercion/string/class_methods/to_time_spec.rb +0 -50
- data/spec/unit/virtus/coercion/symbol/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/coercion/time/class_methods/to_integer_spec.rb +0 -10
- data/spec/unit/virtus/coercion/time/class_methods/to_time_spec.rb +0 -10
- data/spec/unit/virtus/coercion/time_coercions/to_date_spec.rb +0 -33
- data/spec/unit/virtus/coercion/time_coercions/to_datetime_spec.rb +0 -33
- data/spec/unit/virtus/coercion/time_coercions/to_string_spec.rb +0 -18
- data/spec/unit/virtus/coercion/time_coercions/to_time_spec.rb +0 -33
- data/spec/unit/virtus/coercion/true_class/class_methods/to_string_spec.rb +0 -12
- data/spec/unit/virtus/equalizer/append_spec.rb +0 -82
- data/spec/unit/virtus/equalizer/class_method/new_spec.rb +0 -111
- data/spec/unit/virtus/equalizer/methods/eql_spec.rb +0 -47
- data/spec/unit/virtus/equalizer/methods/equal_value_spec.rb +0 -57
- data/spec/unit/virtus/extensions/allowed_writer_methods_spec.rb +0 -25
- data/spec/unit/virtus/extensions/attribute_spec.rb +0 -26
- data/spec/unit/virtus/instance_methods/attributes_spec.rb +0 -140
- data/spec/unit/virtus/instance_methods/element_reference_spec.rb +0 -24
- data/spec/unit/virtus/instance_methods/element_set_spec.rb +0 -28
- data/spec/unit/virtus/instance_methods/freeze_spec.rb +0 -64
- data/spec/unit/virtus/instance_methods/initialize_spec.rb +0 -48
- data/spec/unit/virtus/instance_methods/to_hash_spec.rb +0 -23
- data/spec/unit/virtus/module_extensions/attribute_spec.rb +0 -31
- data/spec/unit/virtus/options/accept_options_spec.rb +0 -37
- data/spec/unit/virtus/options/accepted_options_spec.rb +0 -21
- data/spec/unit/virtus/options/options_spec.rb +0 -34
- data/spec/unit/virtus/type_lookup/class_methods/extended_spec.rb +0 -9
- data/spec/unit/virtus/type_lookup/determine_type_spec.rb +0 -81
- data/spec/unit/virtus/type_lookup/primitive_spec.rb +0 -9
- data/spec/unit/virtus/value_object/class_methods/allowed_writer_methods_spec.rb +0 -15
- data/spec/unit/virtus/value_object/class_methods/attribute_spec.rb +0 -50
- data/spec/unit/virtus/value_object/class_methods/equalizer_spec.rb +0 -24
- data/spec/unit/virtus/value_object/initialize_spec.rb +0 -19
- data/spec/unit/virtus/value_object/instance_methods/clone_spec.rb +0 -21
- data/spec/unit/virtus/value_object/instance_methods/with_spec.rb +0 -31
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '.config' do
|
4
|
+
it 'provides global configuration' do
|
5
|
+
Virtus.config { |config| config.coerce = false }
|
6
|
+
|
7
|
+
expect(Virtus.coerce).to be(false)
|
8
|
+
|
9
|
+
Virtus.config { |config| config.coerce = true }
|
10
|
+
|
11
|
+
expect(Virtus.coerce).to be(true)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '#[]' do
|
4
|
+
subject { object[:test] }
|
5
|
+
|
6
|
+
let(:model) {
|
7
|
+
Class.new {
|
8
|
+
include Virtus
|
9
|
+
|
10
|
+
attribute :test, String
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:object) { model.new }
|
15
|
+
|
16
|
+
before do
|
17
|
+
object.test = 'foo'
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should eq('foo') }
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '#[]=' do
|
4
|
+
subject { object[:test] = 'foo' }
|
5
|
+
|
6
|
+
let(:model) {
|
7
|
+
Class.new {
|
8
|
+
include Virtus
|
9
|
+
|
10
|
+
attribute :test, String
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:object) { model.new }
|
15
|
+
|
16
|
+
specify do
|
17
|
+
expect { subject }.to change { object.test }.from(nil).to('foo')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '#freeze' do
|
4
|
+
subject { object.freeze }
|
5
|
+
|
6
|
+
let(:model) {
|
7
|
+
Class.new {
|
8
|
+
include Virtus
|
9
|
+
|
10
|
+
attribute :name, String, :default => 'foo', :lazy => true
|
11
|
+
attribute :age, Integer, :default => 30
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:object) { model.new }
|
16
|
+
|
17
|
+
it { should be_frozen }
|
18
|
+
|
19
|
+
its(:name) { should eql('foo') }
|
20
|
+
its(:age) { should be(30) }
|
21
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '.model' do
|
4
|
+
share_examples_for 'a model with constructor' do
|
5
|
+
it 'accepts attribute hash' do
|
6
|
+
instance = subject.new(:name => 'Jane')
|
7
|
+
expect(instance.name).to eql('Jane')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
share_examples_for 'a model with mass-assignment' do
|
12
|
+
let(:attributes) do
|
13
|
+
{ :name => 'Jane' }
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
instance.attributes = attributes
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'accepts attribute hash' do
|
21
|
+
expect(instance.attributes).to eql(attributes)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
share_examples_for 'a model with strict mode turned off' do
|
26
|
+
it 'has attributes with strict set to false' do
|
27
|
+
expect(subject.send(:attribute_set)[:name]).to_not be_strict
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with default configuration' do
|
32
|
+
let(:mod) { Virtus.model }
|
33
|
+
|
34
|
+
context 'with a class' do
|
35
|
+
subject { Class.new }
|
36
|
+
|
37
|
+
before do
|
38
|
+
subject.send(:include, mod)
|
39
|
+
subject.attribute :name, String
|
40
|
+
end
|
41
|
+
|
42
|
+
it_behaves_like 'a model with constructor'
|
43
|
+
|
44
|
+
it_behaves_like 'a model with strict mode turned off'
|
45
|
+
|
46
|
+
it_behaves_like 'a model with mass-assignment' do
|
47
|
+
let(:instance) { subject.new }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with an instance' do
|
52
|
+
subject { Class.new.new }
|
53
|
+
|
54
|
+
before do
|
55
|
+
subject.extend(mod)
|
56
|
+
subject.attribute :name, String
|
57
|
+
end
|
58
|
+
|
59
|
+
it_behaves_like 'a model with strict mode turned off'
|
60
|
+
|
61
|
+
it_behaves_like 'a model with mass-assignment' do
|
62
|
+
let(:instance) { subject }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when constructor is disabled' do
|
68
|
+
subject { Class.new.send(:include, mod) }
|
69
|
+
|
70
|
+
let(:mod) { Virtus.model(:constructor => false) }
|
71
|
+
|
72
|
+
it 'does not accept attribute hash in the constructor' do
|
73
|
+
expect { subject.new({}) }.to raise_error(ArgumentError)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when strict mode is enabled' do
|
78
|
+
let(:mod) { Virtus.model(:strict => true) }
|
79
|
+
let(:model) { Class.new }
|
80
|
+
|
81
|
+
context 'with a class' do
|
82
|
+
subject { model.new }
|
83
|
+
|
84
|
+
before do
|
85
|
+
model.send(:include, mod)
|
86
|
+
model.attribute :name, String
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'has attributes with strict set to true' do
|
90
|
+
expect(model.attribute_set[:name]).to be_strict
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'with an instance' do
|
95
|
+
subject { model.new }
|
96
|
+
|
97
|
+
before do
|
98
|
+
subject.extend(mod)
|
99
|
+
subject.attribute :name, String
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'has attributes with strict set to true' do
|
103
|
+
expect(subject.send(:attribute_set)[:name]).to be_strict
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when mass-assignment is disabled' do
|
109
|
+
let(:mod) { Virtus.model(:mass_assignment => false) }
|
110
|
+
let(:model) { Class.new }
|
111
|
+
|
112
|
+
context 'with a class' do
|
113
|
+
subject { model.new }
|
114
|
+
|
115
|
+
before do
|
116
|
+
model.send(:include, mod)
|
117
|
+
end
|
118
|
+
|
119
|
+
it { should_not respond_to(:attributes) }
|
120
|
+
it { should_not respond_to(:attributes=) }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'with an instance' do
|
124
|
+
subject { model.new }
|
125
|
+
|
126
|
+
before do
|
127
|
+
subject.extend(mod)
|
128
|
+
end
|
129
|
+
|
130
|
+
it { should_not respond_to(:attributes) }
|
131
|
+
it { should_not respond_to(:attributes=) }
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '.module' do
|
4
|
+
share_examples_for 'a valid virtus object' do
|
5
|
+
it 'reads and writes attribute' do
|
6
|
+
instance.name = 'Jane'
|
7
|
+
expect(instance.name).to eql('Jane')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
share_examples_for 'an object extended with virtus module' do
|
12
|
+
context 'with default configuration' do
|
13
|
+
subject { Virtus.module }
|
14
|
+
|
15
|
+
it_behaves_like 'a valid virtus object' do
|
16
|
+
let(:instance) { model.new }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with constructor turned off' do
|
21
|
+
subject { Virtus.module(:constructor => false) }
|
22
|
+
|
23
|
+
it_behaves_like 'a valid virtus object' do
|
24
|
+
let(:instance) { model.new }
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'skips including constructor' do
|
28
|
+
expect { model.new({}) }.to raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with mass assignment is turned off' do
|
33
|
+
subject { Virtus.module(:mass_assignment => false) }
|
34
|
+
|
35
|
+
it_behaves_like 'a valid virtus object'
|
36
|
+
|
37
|
+
it 'skips including mass assignment' do
|
38
|
+
expect(instance).not_to respond_to(:attributes)
|
39
|
+
expect(instance).not_to respond_to(:attributes=)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:mod) { Module.new }
|
45
|
+
let(:model) { Class.new }
|
46
|
+
let(:instance) { model.new }
|
47
|
+
|
48
|
+
before do
|
49
|
+
mod.send(:include, subject)
|
50
|
+
mod.attribute :name, String
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with a class' do
|
54
|
+
before do
|
55
|
+
model.send(:include, mod)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'provides attributes for the model' do
|
59
|
+
expect(model.attribute_set[:name]).to be_kind_of(Virtus::Attribute)
|
60
|
+
end
|
61
|
+
|
62
|
+
it_behaves_like 'an object extended with virtus module'
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with a model instance' do
|
66
|
+
before do
|
67
|
+
instance.extend(mod)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'provides attributes for the instance' do
|
71
|
+
expect(instance.send(:attribute_set)[:name]).to be_kind_of(Virtus::Attribute)
|
72
|
+
end
|
73
|
+
|
74
|
+
it_behaves_like 'an object extended with virtus module'
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus, '#set_default_attributes!' do
|
4
|
+
subject { object.set_default_attributes! }
|
5
|
+
|
6
|
+
let(:model) {
|
7
|
+
Class.new {
|
8
|
+
include Virtus
|
9
|
+
|
10
|
+
attribute :name, String, :default => 'foo', :lazy => true
|
11
|
+
attribute :age, Integer, :default => 30
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:object) { model.new }
|
16
|
+
|
17
|
+
before do
|
18
|
+
object.set_default_attributes!
|
19
|
+
end
|
20
|
+
|
21
|
+
it { should be(object) }
|
22
|
+
|
23
|
+
its(:name) { should eql('foo') }
|
24
|
+
its(:age) { should be(30) }
|
25
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Virtus::ValueObject do
|
4
|
+
share_examples_for 'a valid value object' do
|
5
|
+
subject { model.new(attributes) }
|
6
|
+
|
7
|
+
let(:attributes) { Hash[:id => 1, :name => 'Jane Doe'] }
|
8
|
+
|
9
|
+
its(:id) { should be(1) }
|
10
|
+
its(:name) { should eql('Jane Doe') }
|
11
|
+
|
12
|
+
it 'sets private writers' do
|
13
|
+
expect(subject.class.attribute_set[:id]).to_not be_public_writer
|
14
|
+
expect(subject.class.attribute_set[:name]).to_not be_public_writer
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'disallows mass-assignment' do
|
18
|
+
expect(subject.private_methods).to include(:attributes=)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'disallows cloning' do
|
22
|
+
expect(subject.clone).to be(subject)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'defines #eql?' do
|
26
|
+
expect(subject).to eql(subject.class.new(attributes))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'defines #==' do
|
30
|
+
expect(subject == subject.class.new(attributes)).to be(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'defines #hash' do
|
34
|
+
expect(subject.hash).to eql(subject.class.new(attributes).hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'defines #inspect' do
|
38
|
+
expect(subject.inspect).to eql(
|
39
|
+
%(#<Model #{attributes.map { |k, v| "#{k}=#{v.inspect}" }.join(' ')}>)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'using new values {} block' do
|
45
|
+
let(:model) {
|
46
|
+
Class.new {
|
47
|
+
include Virtus.value_object(:coerce => false)
|
48
|
+
|
49
|
+
def self.name
|
50
|
+
'Model'
|
51
|
+
end
|
52
|
+
|
53
|
+
values do
|
54
|
+
attribute :id, Integer
|
55
|
+
attribute :name, String
|
56
|
+
end
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
it_behaves_like 'a valid value object'
|
61
|
+
|
62
|
+
context 'with a model subclass' do
|
63
|
+
let(:subclass) {
|
64
|
+
Class.new(model) {
|
65
|
+
values do
|
66
|
+
attribute :email, String
|
67
|
+
end
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
it_behaves_like 'a valid value object' do
|
72
|
+
subject { subclass.new(attributes) }
|
73
|
+
|
74
|
+
let(:attributes) { Hash[:id => 1, :name => 'Jane Doe', :email => 'jane@doe.com'] }
|
75
|
+
|
76
|
+
its(:email) { should eql('jane@doe.com') }
|
77
|
+
|
78
|
+
it 'sets private writers for additional values' do
|
79
|
+
expect(subclass.attribute_set[:email]).to_not be_public_writer
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'defines valid #== for a subclass' do
|
83
|
+
expect(subject == subject.class.new(attributes.merge(:id => 2))).to be(false)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'using deprecated inclusion' do
|
90
|
+
let(:model) {
|
91
|
+
Class.new {
|
92
|
+
include Virtus::ValueObject
|
93
|
+
|
94
|
+
def self.name
|
95
|
+
'Model'
|
96
|
+
end
|
97
|
+
|
98
|
+
attribute :id, Integer
|
99
|
+
attribute :name, String
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
it_behaves_like 'a valid value object'
|
104
|
+
end
|
105
|
+
end
|
data/virtus.gemspec
CHANGED
@@ -14,8 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.require_paths = [ "lib" ]
|
15
15
|
gem.files = `git ls-files`.split("\n")
|
16
16
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
|
-
gem.extra_rdoc_files = %w[LICENSE README.md TODO]
|
17
|
+
gem.extra_rdoc_files = %w[LICENSE README.md TODO.md]
|
18
18
|
|
19
|
-
gem.add_dependency('backports', '~> 3.3')
|
20
19
|
gem.add_dependency('descendants_tracker', '~> 0.0.1')
|
20
|
+
gem.add_dependency('equalizer', '~> 0.0.7')
|
21
|
+
gem.add_dependency('coercible', '~> 0.2')
|
22
|
+
gem.add_dependency('axiom-types', '~> 0.0.3')
|
21
23
|
end
|
metadata
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0.beta3
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Piotr Solnica
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: descendants_tracker
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,15 +26,15 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.0.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: equalizer
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.0.
|
37
|
+
version: 0.0.7
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,39 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.0.
|
45
|
+
version: 0.0.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: coercible
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: axiom-types
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.0.3
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.0.3
|
46
78
|
description: Attributes on Steroids for Plain Old Ruby Objects
|
47
79
|
email:
|
48
80
|
- piotr.solnica@gmail.com
|
@@ -51,12 +83,13 @@ extensions: []
|
|
51
83
|
extra_rdoc_files:
|
52
84
|
- LICENSE
|
53
85
|
- README.md
|
54
|
-
- TODO
|
86
|
+
- TODO.md
|
55
87
|
files:
|
56
88
|
- .gitignore
|
57
89
|
- .pelusa.yml
|
58
90
|
- .rspec
|
59
|
-
- .
|
91
|
+
- .ruby-gemset
|
92
|
+
- .ruby-version
|
60
93
|
- .travis.yml
|
61
94
|
- .yardopts
|
62
95
|
- Changelog.md
|
@@ -66,67 +99,47 @@ files:
|
|
66
99
|
- LICENSE
|
67
100
|
- README.md
|
68
101
|
- Rakefile
|
69
|
-
- TODO
|
102
|
+
- TODO.md
|
70
103
|
- config/flay.yml
|
71
104
|
- config/flog.yml
|
72
105
|
- config/mutant.yml
|
73
106
|
- config/reek.yml
|
74
|
-
- config/roodi.yml
|
75
107
|
- config/yardstick.yml
|
76
108
|
- lib/virtus.rb
|
77
109
|
- lib/virtus/attribute.rb
|
78
|
-
- lib/virtus/attribute/
|
110
|
+
- lib/virtus/attribute/accessor.rb
|
79
111
|
- lib/virtus/attribute/boolean.rb
|
80
|
-
- lib/virtus/attribute/
|
112
|
+
- lib/virtus/attribute/builder.rb
|
113
|
+
- lib/virtus/attribute/coercer.rb
|
114
|
+
- lib/virtus/attribute/coercible.rb
|
81
115
|
- lib/virtus/attribute/collection.rb
|
82
|
-
- lib/virtus/attribute/date.rb
|
83
|
-
- lib/virtus/attribute/date_time.rb
|
84
|
-
- lib/virtus/attribute/decimal.rb
|
85
116
|
- lib/virtus/attribute/default_value.rb
|
86
117
|
- lib/virtus/attribute/default_value/from_callable.rb
|
87
118
|
- lib/virtus/attribute/default_value/from_clonable.rb
|
88
119
|
- lib/virtus/attribute/default_value/from_symbol.rb
|
89
120
|
- lib/virtus/attribute/embedded_value.rb
|
90
|
-
- lib/virtus/attribute/embedded_value/from_open_struct.rb
|
91
|
-
- lib/virtus/attribute/embedded_value/from_struct.rb
|
92
|
-
- lib/virtus/attribute/float.rb
|
93
121
|
- lib/virtus/attribute/hash.rb
|
94
|
-
- lib/virtus/attribute/
|
95
|
-
- lib/virtus/attribute/
|
96
|
-
- lib/virtus/attribute/object.rb
|
97
|
-
- lib/virtus/attribute/set.rb
|
98
|
-
- lib/virtus/attribute/string.rb
|
99
|
-
- lib/virtus/attribute/symbol.rb
|
100
|
-
- lib/virtus/attribute/time.rb
|
122
|
+
- lib/virtus/attribute/lazy_default.rb
|
123
|
+
- lib/virtus/attribute/strict.rb
|
101
124
|
- lib/virtus/attribute_set.rb
|
102
125
|
- lib/virtus/class_inclusions.rb
|
103
126
|
- lib/virtus/class_methods.rb
|
104
|
-
- lib/virtus/
|
105
|
-
- lib/virtus/
|
106
|
-
- lib/virtus/coercion/date.rb
|
107
|
-
- lib/virtus/coercion/date_time.rb
|
108
|
-
- lib/virtus/coercion/decimal.rb
|
109
|
-
- lib/virtus/coercion/false_class.rb
|
110
|
-
- lib/virtus/coercion/float.rb
|
111
|
-
- lib/virtus/coercion/hash.rb
|
112
|
-
- lib/virtus/coercion/integer.rb
|
113
|
-
- lib/virtus/coercion/numeric.rb
|
114
|
-
- lib/virtus/coercion/object.rb
|
115
|
-
- lib/virtus/coercion/string.rb
|
116
|
-
- lib/virtus/coercion/symbol.rb
|
117
|
-
- lib/virtus/coercion/time.rb
|
118
|
-
- lib/virtus/coercion/time_coercions.rb
|
119
|
-
- lib/virtus/coercion/true_class.rb
|
127
|
+
- lib/virtus/configuration.rb
|
128
|
+
- lib/virtus/const_missing_extensions.rb
|
120
129
|
- lib/virtus/extensions.rb
|
121
130
|
- lib/virtus/instance_methods.rb
|
131
|
+
- lib/virtus/model.rb
|
132
|
+
- lib/virtus/module_builder.rb
|
122
133
|
- lib/virtus/module_extensions.rb
|
123
134
|
- lib/virtus/support/equalizer.rb
|
124
135
|
- lib/virtus/support/options.rb
|
125
136
|
- lib/virtus/support/type_lookup.rb
|
126
137
|
- lib/virtus/value_object.rb
|
127
138
|
- lib/virtus/version.rb
|
139
|
+
- spec/integration/building_module_spec.rb
|
128
140
|
- spec/integration/collection_member_coercion_spec.rb
|
129
141
|
- spec/integration/custom_attributes_spec.rb
|
142
|
+
- spec/integration/custom_collection_attributes_spec.rb
|
130
143
|
- spec/integration/default_values_spec.rb
|
131
144
|
- spec/integration/defining_attributes_spec.rb
|
132
145
|
- spec/integration/embedded_value_spec.rb
|
@@ -144,73 +157,23 @@ files:
|
|
144
157
|
- spec/shared/idempotent_method_behaviour.rb
|
145
158
|
- spec/shared/options_class_method.rb
|
146
159
|
- spec/spec_helper.rb
|
147
|
-
- spec/unit/virtus/attribute/
|
148
|
-
- spec/unit/virtus/attribute/boolean/coerce_spec.rb
|
149
|
-
- spec/unit/virtus/attribute/boolean/define_reader_method_spec.rb
|
150
|
-
- spec/unit/virtus/attribute/boolean/value_coerced_spec.rb
|
151
|
-
- spec/unit/virtus/attribute/boolean_spec.rb
|
152
|
-
- spec/unit/virtus/attribute/class/coerce_spec.rb
|
153
|
-
- spec/unit/virtus/attribute/class_methods/accessor_spec.rb
|
160
|
+
- spec/unit/virtus/attribute/boolean/value_coerced_predicate_spec.rb
|
154
161
|
- spec/unit/virtus/attribute/class_methods/build_spec.rb
|
155
|
-
- spec/unit/virtus/attribute/class_methods/
|
156
|
-
- spec/unit/virtus/attribute/class_methods/default_spec.rb
|
157
|
-
- spec/unit/virtus/attribute/class_methods/determine_type_spec.rb
|
158
|
-
- spec/unit/virtus/attribute/class_methods/merge_options_spec.rb
|
159
|
-
- spec/unit/virtus/attribute/class_methods/primitive_spec.rb
|
160
|
-
- spec/unit/virtus/attribute/class_methods/reader_spec.rb
|
161
|
-
- spec/unit/virtus/attribute/class_methods/writer_spec.rb
|
162
|
+
- spec/unit/virtus/attribute/class_methods/coerce_spec.rb
|
162
163
|
- spec/unit/virtus/attribute/coerce_spec.rb
|
163
|
-
- spec/unit/virtus/attribute/
|
164
|
-
- spec/unit/virtus/attribute/collection/class_methods/
|
165
|
-
- spec/unit/virtus/attribute/collection/coerce_and_append_member_spec.rb
|
164
|
+
- spec/unit/virtus/attribute/coercible_predicate_spec.rb
|
165
|
+
- spec/unit/virtus/attribute/collection/class_methods/build_spec.rb
|
166
166
|
- spec/unit/virtus/attribute/collection/coerce_spec.rb
|
167
|
-
- spec/unit/virtus/attribute/
|
168
|
-
- spec/unit/virtus/attribute/
|
169
|
-
- spec/unit/virtus/attribute/collection/new_collection_spec.rb
|
170
|
-
- spec/unit/virtus/attribute/date/coerce_spec.rb
|
171
|
-
- spec/unit/virtus/attribute/date/value_coerced_spec.rb
|
172
|
-
- spec/unit/virtus/attribute/date_time/coerce_spec.rb
|
173
|
-
- spec/unit/virtus/attribute/decimal/coerce_spec.rb
|
174
|
-
- spec/unit/virtus/attribute/default_spec.rb
|
175
|
-
- spec/unit/virtus/attribute/default_value/call_spec.rb
|
176
|
-
- spec/unit/virtus/attribute/default_value/class_methods/build_spec.rb
|
177
|
-
- spec/unit/virtus/attribute/default_value/class_methods/new_spec.rb
|
178
|
-
- spec/unit/virtus/attribute/default_value/from_callable/call_spec.rb
|
179
|
-
- spec/unit/virtus/attribute/default_value/from_callable/class_methods/handle_spec.rb
|
180
|
-
- spec/unit/virtus/attribute/default_value/from_clonable/call_spec.rb
|
181
|
-
- spec/unit/virtus/attribute/default_value/from_clonable/class_methods/handle_spec.rb
|
182
|
-
- spec/unit/virtus/attribute/default_value/from_symbol/call_spec.rb
|
183
|
-
- spec/unit/virtus/attribute/default_value/from_symbol/class_methods/handle_spec.rb
|
184
|
-
- spec/unit/virtus/attribute/default_value/value_spec.rb
|
185
|
-
- spec/unit/virtus/attribute/define_accessor_methods_spec.rb
|
186
|
-
- spec/unit/virtus/attribute/define_reader_method_spec.rb
|
187
|
-
- spec/unit/virtus/attribute/define_writer_method_spec.rb
|
188
|
-
- spec/unit/virtus/attribute/embedded_value/class_methods/determine_type_spec.rb
|
189
|
-
- spec/unit/virtus/attribute/embedded_value/class_methods/merge_options_spec.rb
|
167
|
+
- spec/unit/virtus/attribute/custom_collection_spec.rb
|
168
|
+
- spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
|
190
169
|
- spec/unit/virtus/attribute/embedded_value/coerce_spec.rb
|
191
|
-
- spec/unit/virtus/attribute/embedded_value/from_open_struct/coerce_spec.rb
|
192
|
-
- spec/unit/virtus/attribute/embedded_value/from_struct/coerce_spec.rb
|
193
|
-
- spec/unit/virtus/attribute/float/coerce_spec.rb
|
194
170
|
- spec/unit/virtus/attribute/get_spec.rb
|
195
|
-
- spec/unit/virtus/attribute/hash/class_methods/
|
171
|
+
- spec/unit/virtus/attribute/hash/class_methods/build_spec.rb
|
196
172
|
- spec/unit/virtus/attribute/hash/coerce_spec.rb
|
197
|
-
- spec/unit/virtus/attribute/
|
198
|
-
- spec/unit/virtus/attribute/
|
199
|
-
- spec/unit/virtus/attribute/inspect_spec.rb
|
200
|
-
- spec/unit/virtus/attribute/integer/coerce_spec.rb
|
201
|
-
- spec/unit/virtus/attribute/name_spec.rb
|
202
|
-
- spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb
|
203
|
-
- spec/unit/virtus/attribute/numeric/class_methods/max_spec.rb
|
204
|
-
- spec/unit/virtus/attribute/numeric/class_methods/min_spec.rb
|
205
|
-
- spec/unit/virtus/attribute/options_spec.rb
|
206
|
-
- spec/unit/virtus/attribute/public_reader_spec.rb
|
207
|
-
- spec/unit/virtus/attribute/public_writer_spec.rb
|
208
|
-
- spec/unit/virtus/attribute/set/coerce_spec.rb
|
173
|
+
- spec/unit/virtus/attribute/lazy_predicate_spec.rb
|
174
|
+
- spec/unit/virtus/attribute/set_default_value_spec.rb
|
209
175
|
- spec/unit/virtus/attribute/set_spec.rb
|
210
|
-
- spec/unit/virtus/attribute/
|
211
|
-
- spec/unit/virtus/attribute/symbol/coerce_spec.rb
|
212
|
-
- spec/unit/virtus/attribute/time/coerce_spec.rb
|
213
|
-
- spec/unit/virtus/attribute/value_coerced_spec.rb
|
176
|
+
- spec/unit/virtus/attribute/value_coerced_predicate_spec.rb
|
214
177
|
- spec/unit/virtus/attribute_set/append_spec.rb
|
215
178
|
- spec/unit/virtus/attribute_set/define_reader_method_spec.rb
|
216
179
|
- spec/unit/virtus/attribute_set/define_writer_method_spec.rb
|
@@ -220,90 +183,18 @@ files:
|
|
220
183
|
- spec/unit/virtus/attribute_set/inspect_spec.rb
|
221
184
|
- spec/unit/virtus/attribute_set/merge_spec.rb
|
222
185
|
- spec/unit/virtus/attribute_set/reset_spec.rb
|
223
|
-
- spec/unit/virtus/
|
224
|
-
- spec/unit/virtus/
|
225
|
-
- spec/unit/virtus/
|
226
|
-
- spec/unit/virtus/class_methods/
|
227
|
-
- spec/unit/virtus/
|
228
|
-
- spec/unit/virtus/
|
229
|
-
- spec/unit/virtus/
|
230
|
-
- spec/unit/virtus/
|
231
|
-
- spec/unit/virtus/
|
232
|
-
- spec/unit/virtus/
|
233
|
-
- spec/unit/virtus/
|
234
|
-
- spec/unit/virtus/
|
235
|
-
- spec/unit/virtus/coercion/date_time/class_methods/to_date_spec.rb
|
236
|
-
- spec/unit/virtus/coercion/date_time/class_methods/to_datetime_spec.rb
|
237
|
-
- spec/unit/virtus/coercion/date_time/class_methods/to_string_spec.rb
|
238
|
-
- spec/unit/virtus/coercion/date_time/class_methods/to_time_spec.rb
|
239
|
-
- spec/unit/virtus/coercion/decimal/class_methods/to_decimal_spec.rb
|
240
|
-
- spec/unit/virtus/coercion/decimal/class_methods/to_float_spec.rb
|
241
|
-
- spec/unit/virtus/coercion/decimal/class_methods/to_integer_spec.rb
|
242
|
-
- spec/unit/virtus/coercion/decimal/class_methods/to_string_spec.rb
|
243
|
-
- spec/unit/virtus/coercion/false_class/class_methods/to_string_spec.rb
|
244
|
-
- spec/unit/virtus/coercion/float/class_methods/to_decimal_spec.rb
|
245
|
-
- spec/unit/virtus/coercion/float/class_methods/to_float_spec.rb
|
246
|
-
- spec/unit/virtus/coercion/float/class_methods/to_integer_spec.rb
|
247
|
-
- spec/unit/virtus/coercion/float/class_methods/to_string_spec.rb
|
248
|
-
- spec/unit/virtus/coercion/hash/class_methods/to_date_spec.rb
|
249
|
-
- spec/unit/virtus/coercion/hash/class_methods/to_datetime_spec.rb
|
250
|
-
- spec/unit/virtus/coercion/hash/class_methods/to_time_spec.rb
|
251
|
-
- spec/unit/virtus/coercion/integer/class_methods/to_boolean_spec.rb
|
252
|
-
- spec/unit/virtus/coercion/integer/class_methods/to_decimal_spec.rb
|
253
|
-
- spec/unit/virtus/coercion/integer/class_methods/to_float_spec.rb
|
254
|
-
- spec/unit/virtus/coercion/integer/class_methods/to_integer_spec.rb
|
255
|
-
- spec/unit/virtus/coercion/integer/class_methods/to_string_spec.rb
|
256
|
-
- spec/unit/virtus/coercion/numeric/class_methods/to_decimal_spec.rb
|
257
|
-
- spec/unit/virtus/coercion/numeric/class_methods/to_float_spec.rb
|
258
|
-
- spec/unit/virtus/coercion/numeric/class_methods/to_integer_spec.rb
|
259
|
-
- spec/unit/virtus/coercion/numeric/class_methods/to_string_spec.rb
|
260
|
-
- spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
|
261
|
-
- spec/unit/virtus/coercion/object/class_methods/to_array_spec.rb
|
262
|
-
- spec/unit/virtus/coercion/object/class_methods/to_hash_spec.rb
|
263
|
-
- spec/unit/virtus/coercion/object/class_methods/to_integer_spec.rb
|
264
|
-
- spec/unit/virtus/coercion/object/class_methods/to_string_spec.rb
|
265
|
-
- spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
|
266
|
-
- spec/unit/virtus/coercion/string/class_methods/to_constant_spec.rb
|
267
|
-
- spec/unit/virtus/coercion/string/class_methods/to_date_spec.rb
|
268
|
-
- spec/unit/virtus/coercion/string/class_methods/to_datetime_spec.rb
|
269
|
-
- spec/unit/virtus/coercion/string/class_methods/to_decimal_spec.rb
|
270
|
-
- spec/unit/virtus/coercion/string/class_methods/to_float_spec.rb
|
271
|
-
- spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
|
272
|
-
- spec/unit/virtus/coercion/string/class_methods/to_symbol_spec.rb
|
273
|
-
- spec/unit/virtus/coercion/string/class_methods/to_time_spec.rb
|
274
|
-
- spec/unit/virtus/coercion/symbol/class_methods/to_string_spec.rb
|
275
|
-
- spec/unit/virtus/coercion/time/class_methods/to_integer_spec.rb
|
276
|
-
- spec/unit/virtus/coercion/time/class_methods/to_time_spec.rb
|
277
|
-
- spec/unit/virtus/coercion/time_coercions/to_date_spec.rb
|
278
|
-
- spec/unit/virtus/coercion/time_coercions/to_datetime_spec.rb
|
279
|
-
- spec/unit/virtus/coercion/time_coercions/to_string_spec.rb
|
280
|
-
- spec/unit/virtus/coercion/time_coercions/to_time_spec.rb
|
281
|
-
- spec/unit/virtus/coercion/true_class/class_methods/to_string_spec.rb
|
282
|
-
- spec/unit/virtus/equalizer/append_spec.rb
|
283
|
-
- spec/unit/virtus/equalizer/class_method/new_spec.rb
|
284
|
-
- spec/unit/virtus/equalizer/methods/eql_spec.rb
|
285
|
-
- spec/unit/virtus/equalizer/methods/equal_value_spec.rb
|
286
|
-
- spec/unit/virtus/extensions/allowed_writer_methods_spec.rb
|
287
|
-
- spec/unit/virtus/extensions/attribute_spec.rb
|
288
|
-
- spec/unit/virtus/instance_methods/attributes_spec.rb
|
289
|
-
- spec/unit/virtus/instance_methods/element_reference_spec.rb
|
290
|
-
- spec/unit/virtus/instance_methods/element_set_spec.rb
|
291
|
-
- spec/unit/virtus/instance_methods/freeze_spec.rb
|
292
|
-
- spec/unit/virtus/instance_methods/initialize_spec.rb
|
293
|
-
- spec/unit/virtus/instance_methods/to_hash_spec.rb
|
294
|
-
- spec/unit/virtus/module_extensions/attribute_spec.rb
|
295
|
-
- spec/unit/virtus/options/accept_options_spec.rb
|
296
|
-
- spec/unit/virtus/options/accepted_options_spec.rb
|
297
|
-
- spec/unit/virtus/options/options_spec.rb
|
298
|
-
- spec/unit/virtus/type_lookup/class_methods/extended_spec.rb
|
299
|
-
- spec/unit/virtus/type_lookup/determine_type_spec.rb
|
300
|
-
- spec/unit/virtus/type_lookup/primitive_spec.rb
|
301
|
-
- spec/unit/virtus/value_object/class_methods/allowed_writer_methods_spec.rb
|
302
|
-
- spec/unit/virtus/value_object/class_methods/attribute_spec.rb
|
303
|
-
- spec/unit/virtus/value_object/class_methods/equalizer_spec.rb
|
304
|
-
- spec/unit/virtus/value_object/initialize_spec.rb
|
305
|
-
- spec/unit/virtus/value_object/instance_methods/clone_spec.rb
|
306
|
-
- spec/unit/virtus/value_object/instance_methods/with_spec.rb
|
186
|
+
- spec/unit/virtus/attribute_spec.rb
|
187
|
+
- spec/unit/virtus/attributes_reader_spec.rb
|
188
|
+
- spec/unit/virtus/attributes_writer_spec.rb
|
189
|
+
- spec/unit/virtus/class_methods/new_spec.rb
|
190
|
+
- spec/unit/virtus/config_spec.rb
|
191
|
+
- spec/unit/virtus/element_reader_spec.rb
|
192
|
+
- spec/unit/virtus/element_writer_spec.rb
|
193
|
+
- spec/unit/virtus/freeze_spec.rb
|
194
|
+
- spec/unit/virtus/model_spec.rb
|
195
|
+
- spec/unit/virtus/module_spec.rb
|
196
|
+
- spec/unit/virtus/set_default_attributes_spec.rb
|
197
|
+
- spec/unit/virtus/value_object_spec.rb
|
307
198
|
- virtus.gemspec
|
308
199
|
homepage: https://github.com/solnic/virtus
|
309
200
|
licenses: []
|
@@ -320,12 +211,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
320
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
321
212
|
none: false
|
322
213
|
requirements:
|
323
|
-
- - ! '
|
214
|
+
- - ! '>'
|
324
215
|
- !ruby/object:Gem::Version
|
325
|
-
version:
|
216
|
+
version: 1.3.1
|
326
217
|
requirements: []
|
327
218
|
rubyforge_project:
|
328
|
-
rubygems_version: 1.8.
|
219
|
+
rubygems_version: 1.8.23
|
329
220
|
signing_key:
|
330
221
|
specification_version: 3
|
331
222
|
summary: Attributes on Steroids for Plain Old Ruby Objects
|