protobuf-activerecord 3.0.0.rc3 → 3.0.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4138119bd9c5f0638a76a08f3a796ceda7f94163
4
- data.tar.gz: 1659d777be06f6318e7a2a4b3ccf61ca8b1eeb52
3
+ metadata.gz: 7607179e8934a9674f488525de0ab8186f78907b
4
+ data.tar.gz: 7df784557494dcfaf362800e3ad71df46c556454
5
5
  SHA512:
6
- metadata.gz: 2e25a6022d48d954920499422fc197bde2bec941d7071f9d6c0fe56dc7072b1f398958b4e87fba60b41aa75eaed3aeaa7aa80ecd52265fdb3b5a69da3b26c804
7
- data.tar.gz: 4c24f5639552493d4a645c3f2b751d62ecd53e0f085f5383df6116a2796ebac910e7acd130cab6b618eb300e7568572afdd0beef616926833070fcf172a1b9f3
6
+ metadata.gz: d6b300dfc3aa2382b3daf8490619eb8313af9c7ac1b231527a814ab18926478c1db900bb4b024e2ff799cb6aa4679aada64a4851a0818bfb7c9292d0bdda8d9c
7
+ data.tar.gz: 0737fdd0bb4e2dd0b41fc0655361d7fdbc577190f58017d8b5d6a0ebae020ed4acd9e94bfc4fce63adc1b686957163dd0b8681364149341d6a9af955c99fdbae
@@ -2,6 +2,7 @@ require 'protobuf/active_record/attribute_methods'
2
2
  require 'protobuf/active_record/columns'
3
3
  require 'protobuf/active_record/errors'
4
4
  require 'protobuf/active_record/mass_assignment_security'
5
+ require 'protobuf/active_record/nested_attributes'
5
6
  require 'protobuf/active_record/persistence'
6
7
  require 'protobuf/active_record/scope'
7
8
  require 'protobuf/active_record/serialization'
@@ -16,6 +17,7 @@ module Protobuf
16
17
  included do
17
18
  include Protobuf::ActiveRecord::AttributeMethods
18
19
  include Protobuf::ActiveRecord::Columns
20
+ include Protobuf::ActiveRecord::NestedAttributes
19
21
  include Protobuf::ActiveRecord::Serialization
20
22
  include Protobuf::ActiveRecord::Scope
21
23
  include Protobuf::ActiveRecord::Transformation
@@ -0,0 +1,31 @@
1
+ module Protobuf
2
+ module ActiveRecord
3
+ module NestedAttributes
4
+ extend ::ActiveSupport::Concern
5
+
6
+ included do
7
+ include ::Heredity::InheritableClassInstanceVariables
8
+
9
+ class << self
10
+ attr_accessor :_protobuf_nested_attributes
11
+ end
12
+
13
+ @_protobuf_nested_attributes = []
14
+
15
+ inheritable_attributes :_protobuf_nested_attributes
16
+ end
17
+
18
+ module ClassMethods
19
+ # :nodoc
20
+ def accepts_nested_attributes_for(*attr_names)
21
+ attribute_names = attr_names.dup
22
+ attribute_names.extract_options!
23
+
24
+ super
25
+
26
+ self._protobuf_nested_attributes += attribute_names.map { |name| "#{name}_attributes" }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -32,7 +32,9 @@ module Protobuf
32
32
  proto.has_field?(key) && !field.repeated?
33
33
  end
34
34
 
35
- attribute_fields = _filtered_attributes.inject({}) do |hash, column_name|
35
+ filtered_attributes = _filtered_attributes + _protobuf_nested_attributes
36
+
37
+ attribute_fields = filtered_attributes.inject({}) do |hash, column_name|
36
38
  symbolized_column = column_name.to_sym
37
39
 
38
40
  if fields.has_key?(symbolized_column) ||
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module ActiveRecord
3
- VERSION = "3.0.0.rc3"
3
+ VERSION = "3.0.0.rc4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc3
4
+ version: 3.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -187,6 +187,7 @@ files:
187
187
  - lib/protobuf/active_record/mass_assignment_security/persistence.rb
188
188
  - lib/protobuf/active_record/mass_assignment_security/transformation.rb
189
189
  - lib/protobuf/active_record/model.rb
190
+ - lib/protobuf/active_record/nested_attributes.rb
190
191
  - lib/protobuf/active_record/persistence.rb
191
192
  - lib/protobuf/active_record/railtie.rb
192
193
  - lib/protobuf/active_record/scope.rb