protobuf-activerecord 1.2.3 → 1.2.4
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.
@@ -26,9 +26,7 @@ module Protoable
|
|
26
26
|
fields = proto.to_hash
|
27
27
|
fields.select! { |key, value| proto.has_field?(key) && !proto.get_field_by_name(key).repeated? }
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
attribute_fields = attributes.inject({}) do |hash, column_name|
|
29
|
+
attribute_fields = _filtered_attributes.inject({}) do |hash, column_name|
|
32
30
|
symbolized_column = column_name.to_sym
|
33
31
|
|
34
32
|
if fields.has_key?(symbolized_column) ||
|
@@ -42,6 +40,17 @@ module Protoable
|
|
42
40
|
attribute_fields
|
43
41
|
end
|
44
42
|
|
43
|
+
# Filters protected attributes from the available attributes list. When
|
44
|
+
# set through accessible attributes, returns the accessible attributes.
|
45
|
+
# When set through protected attributes, returns the attributes minus any
|
46
|
+
# protected attributes.
|
47
|
+
#
|
48
|
+
def _filtered_attributes
|
49
|
+
return accessible_attributes.to_a if accessible_attributes.present?
|
50
|
+
|
51
|
+
return self.new.attributes.keys - protected_attributes.to_a
|
52
|
+
end
|
53
|
+
|
45
54
|
# Creates a hash of attributes from a given protobuf message.
|
46
55
|
#
|
47
56
|
# It converts and transforms field values using the field converters and
|
@@ -53,7 +62,7 @@ module Protoable
|
|
53
62
|
attributes = attribute_fields.inject({}) do |hash, (key, value)|
|
54
63
|
if _protobuf_attribute_transformers.has_key?(key)
|
55
64
|
attribute = _protobuf_attribute_transformers[key].call(proto)
|
56
|
-
hash[key] = attribute unless attribute.nil?
|
65
|
+
hash[key] = attribute unless attribute.nil?
|
57
66
|
else
|
58
67
|
hash[key] = _protobuf_convert_fields_to_columns(key, value)
|
59
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
240
|
version: '0'
|
241
241
|
segments:
|
242
242
|
- 0
|
243
|
-
hash:
|
243
|
+
hash: 811709440297212247
|
244
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
245
|
none: false
|
246
246
|
requirements:
|
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: 811709440297212247
|
253
253
|
requirements: []
|
254
254
|
rubyforge_project:
|
255
255
|
rubygems_version: 1.8.24
|