active_attr 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of active_attr might be problematic. Click here for more details.

@@ -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
@@ -83,7 +83,7 @@ module ActiveAttr
83
83
  # @return [String] Description
84
84
  # @private
85
85
  def description
86
- "has #{@description}"
86
+ "have #{@description}"
87
87
  end
88
88
 
89
89
  # @private
@@ -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
@@ -1,5 +1,5 @@
1
1
  module ActiveAttr
2
2
  # Complete version string
3
3
  # @since 0.1.0
4
- VERSION = "0.8.1"
4
+ VERSION = "0.8.2"
5
5
  end
@@ -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 == "has attribute named first_name"
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 == %{has attribute named first_name with a default value of "John"}
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 == %{has attribute named first_name with a default value of nil}
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 == %{has attribute named admin with a default value of false}
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 == %{has attribute named first_name of type String}
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 == %{has attribute named first_name of type String with a default value of "John"}
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.1
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-10 00:00:00.000000000 Z
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: 3855427455424208454
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: 3855427455424208454
270
+ hash: 4300701994250441462
271
271
  requirements: []
272
272
  rubyforge_project:
273
273
  rubygems_version: 1.8.25