active_attr 0.4.0 → 0.4.1

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,7 @@
1
+ # ActiveAttr 0.4.1 (November 27, 2011) #
2
+
3
+ * Implemented ActiveModel serialization in Model
4
+
1
5
  # ActiveAttr 0.4.0 (November 26, 2011) #
2
6
 
3
7
  * Added Model
@@ -40,7 +40,7 @@ module ActiveAttr
40
40
 
41
41
  included do
42
42
  class_attribute :logger
43
- self.logger = ActiveAttr::Logger.logger
43
+ self.logger = Logger.logger
44
44
  end
45
45
  end
46
46
  end
@@ -3,6 +3,7 @@ require "active_attr/block_initialization"
3
3
  require "active_attr/logger"
4
4
  require "active_attr/mass_assignment_security"
5
5
  require "active_attr/query_attributes"
6
+ require "active_model"
6
7
  require "active_support/concern"
7
8
 
8
9
  module ActiveAttr
@@ -24,5 +25,13 @@ module ActiveAttr
24
25
  include Logger
25
26
  include MassAssignmentSecurity
26
27
  include QueryAttributes
28
+
29
+ if defined? ActiveModel::Serializable
30
+ include ActiveModel::Serializable::JSON
31
+ include ActiveModel::Serializable::XML
32
+ else
33
+ include ActiveModel::Serializers::JSON
34
+ include ActiveModel::Serializers::Xml
35
+ end
27
36
  end
28
37
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveAttr
2
2
  # Complete version string
3
3
  # @since 0.1.0
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
@@ -1,5 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "active_attr/model"
3
+ require "active_support/core_ext/hash/conversions"
4
+ require "active_support/json/decoding"
3
5
 
4
6
  module ActiveAttr
5
7
  describe Model do
@@ -67,5 +69,19 @@ module ActiveAttr
67
69
  it "does not use strict mass assignment" do
68
70
  expect { subject.assign_attributes :middle_initial => "J" }.not_to raise_error
69
71
  end
72
+
73
+ it "serializes to/from JSON" do
74
+ subject.first_name = "Chris"
75
+ model_class.new.from_json(subject.to_json).first_name.should == "Chris"
76
+ end
77
+
78
+ it "serializes to/from XML" do
79
+ subject.first_name = "Chris"
80
+ model_class.new.from_xml(subject.to_xml).first_name.should == "Chris"
81
+ end
82
+
83
+ it "supports attribute name translation" do
84
+ model_class.human_attribute_name(:first_name).should == "First name"
85
+ end
70
86
  end
71
87
  end
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.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-11-27 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &70208496667400 !ruby/object:Gem::Requirement
17
+ requirement: &70212854595820 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70208496667400
25
+ version_requirements: *70212854595820
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &70208496659840 !ruby/object:Gem::Requirement
28
+ requirement: &70212854610300 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70208496659840
36
+ version_requirements: *70212854610300
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &70208496720580 !ruby/object:Gem::Requirement
39
+ requirement: &70212854618100 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '1.0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70208496720580
47
+ version_requirements: *70212854618100
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: factory_girl
50
- requirement: &70208496732300 !ruby/object:Gem::Requirement
50
+ requirement: &70212854630340 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '2.2'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70208496732300
58
+ version_requirements: *70212854630340
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &70208496743100 !ruby/object:Gem::Requirement
61
+ requirement: &70212858706240 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.9.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70208496743100
69
+ version_requirements: *70212858706240
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
- requirement: &70208496750220 !ruby/object:Gem::Requirement
72
+ requirement: &70212863308060 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '2.6'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70208496750220
80
+ version_requirements: *70212863308060
81
81
  description: Create plain old ruby models without reinventing the wheel.
82
82
  email:
83
83
  - cgriego@gmail.com
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  segments:
159
159
  - 0
160
- hash: 2277450769391114254
160
+ hash: 3302118214315982046
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  none: false
163
163
  requirements:
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  segments:
168
168
  - 0
169
- hash: 2277450769391114254
169
+ hash: 3302118214315982046
170
170
  requirements: []
171
171
  rubyforge_project: active_attr
172
172
  rubygems_version: 1.8.10