active_attr 0.8.1 → 0.8.2
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.
Potentially problematic release.
This version of active_attr might be problematic. Click here for more details.
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# ActiveAttr 0.8.2 (June 16, 2013) #
|
2
|
+
|
3
|
+
* #108 Fix grammar in HaveAttributeMatcher#description (Matt Hodan)
|
4
|
+
* #110 #116 Improve performance of typecasting (Roman Heinrich)
|
5
|
+
|
1
6
|
# ActiveAttr 0.8.1 (June 9, 2013) #
|
2
7
|
|
3
8
|
* #121 Fix compatibility with ActiveModel Serializers gem by dropping support
|
@@ -24,6 +24,18 @@ module ActiveAttr
|
|
24
24
|
#
|
25
25
|
# @since 0.5.0
|
26
26
|
module Typecasting
|
27
|
+
# @private
|
28
|
+
TYPECASTER_MAP = {
|
29
|
+
BigDecimal => BigDecimalTypecaster,
|
30
|
+
Boolean => BooleanTypecaster,
|
31
|
+
Date => DateTypecaster,
|
32
|
+
DateTime => DateTimeTypecaster,
|
33
|
+
Float => FloatTypecaster,
|
34
|
+
Integer => IntegerTypecaster,
|
35
|
+
Object => ObjectTypecaster,
|
36
|
+
String => StringTypecaster,
|
37
|
+
}.freeze
|
38
|
+
|
27
39
|
# Typecasts a value using a Class
|
28
40
|
#
|
29
41
|
# @param [#call] typecaster The typecaster to use for typecasting
|
@@ -47,17 +59,7 @@ module ActiveAttr
|
|
47
59
|
#
|
48
60
|
# @since 0.6.0
|
49
61
|
def typecaster_for(type)
|
50
|
-
typecaster =
|
51
|
-
BigDecimal => BigDecimalTypecaster,
|
52
|
-
Boolean => BooleanTypecaster,
|
53
|
-
Date => DateTypecaster,
|
54
|
-
DateTime => DateTimeTypecaster,
|
55
|
-
Float => FloatTypecaster,
|
56
|
-
Integer => IntegerTypecaster,
|
57
|
-
Object => ObjectTypecaster,
|
58
|
-
String => StringTypecaster,
|
59
|
-
}[type]
|
60
|
-
|
62
|
+
typecaster = TYPECASTER_MAP[type]
|
61
63
|
typecaster.new if typecaster
|
62
64
|
end
|
63
65
|
end
|
data/lib/active_attr/version.rb
CHANGED
@@ -10,28 +10,28 @@ module ActiveAttr
|
|
10
10
|
|
11
11
|
describe "#description" do
|
12
12
|
it "returns a description appropriate to the expectation" do
|
13
|
-
described_class.new(:first_name).description.should == "
|
13
|
+
described_class.new(:first_name).description.should == "have attribute named first_name"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "mentions the default value if set" do
|
17
|
-
described_class.new(:first_name).with_default_value_of("John").description.should == %{
|
17
|
+
described_class.new(:first_name).with_default_value_of("John").description.should == %{have attribute named first_name with a default value of "John"}
|
18
18
|
end
|
19
19
|
|
20
20
|
it "mentions the default value if set to nil" do
|
21
|
-
described_class.new(:first_name).with_default_value_of(nil).description.should == %{
|
21
|
+
described_class.new(:first_name).with_default_value_of(nil).description.should == %{have attribute named first_name with a default value of nil}
|
22
22
|
end
|
23
23
|
|
24
24
|
it "mentions the default value if set to false" do
|
25
|
-
described_class.new(:admin).with_default_value_of(false).description.should == %{
|
25
|
+
described_class.new(:admin).with_default_value_of(false).description.should == %{have attribute named admin with a default value of false}
|
26
26
|
end
|
27
27
|
|
28
28
|
it "mentions the type if set" do
|
29
|
-
described_class.new(:first_name).of_type(String).description.should == %{
|
29
|
+
described_class.new(:first_name).of_type(String).description.should == %{have attribute named first_name of type String}
|
30
30
|
end
|
31
31
|
|
32
32
|
it "mentions both the type and default if both are set" do
|
33
33
|
description = described_class.new(:first_name).of_type(String).with_default_value_of("John").description
|
34
|
-
description.should == %{
|
34
|
+
description.should == %{have attribute named first_name of type String with a default value of "John"}
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-06-
|
13
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -258,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
258
258
|
version: '0'
|
259
259
|
segments:
|
260
260
|
- 0
|
261
|
-
hash:
|
261
|
+
hash: 4300701994250441462
|
262
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
263
|
none: false
|
264
264
|
requirements:
|
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
version: '0'
|
268
268
|
segments:
|
269
269
|
- 0
|
270
|
-
hash:
|
270
|
+
hash: 4300701994250441462
|
271
271
|
requirements: []
|
272
272
|
rubyforge_project:
|
273
273
|
rubygems_version: 1.8.25
|