protobuf-activerecord 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ desc "Run specs"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  desc "Run specs (default)"
8
- task :default => :spec
8
+ task :default => :spec
@@ -1,10 +1,10 @@
1
- require 'protoable/inheritable_class_instance_variables'
1
+ require 'heredity/inheritable_class_instance_variables'
2
2
 
3
3
  module Protoable
4
4
  module Fields
5
5
  def self.extended(klass)
6
6
  klass.extend Protoable::Fields::ClassMethods
7
- klass.__send__(:include, Protoable::InheritableClassInstanceVariables)
7
+ klass.__send__(:include, ::Heredity::InheritableClassInstanceVariables)
8
8
 
9
9
  klass.class_eval do
10
10
  class << self
@@ -1,8 +1,10 @@
1
+ require 'heredity/inheritable_class_instance_variables'
2
+
1
3
  module Protoable
2
4
  module Serialization
3
5
  def self.included(klass)
4
6
  klass.extend Protoable::Serialization::ClassMethods
5
- klass.__send__(:include, Protoable::InheritableClassInstanceVariables)
7
+ klass.__send__(:include, ::Heredity::InheritableClassInstanceVariables)
6
8
 
7
9
  klass.class_eval do
8
10
  class << self
@@ -14,8 +16,7 @@ module Protoable
14
16
  @_protobuf_column_converters = {}
15
17
  @protobuf_fields = []
16
18
 
17
- # NOTE: Make sure each inherited object has the database layout
18
- inheritable_attributes :protobuf_fields, :_protobuf_column_converters
19
+ inheritable_attributes :_protobuf_column_converters, :protobuf_fields, :protobuf_message
19
20
  end
20
21
  end
21
22
 
@@ -77,9 +78,9 @@ module Protoable
77
78
  #
78
79
  def protobuf_message(message = nil)
79
80
  unless message.nil?
80
- @_protobuf_message = message.to_s.classify.constantize
81
+ @protobuf_message = message.to_s.classify.constantize
81
82
 
82
- self.protobuf_fields = @_protobuf_message.fields.compact.map do |field|
83
+ self.protobuf_fields = @protobuf_message.fields.compact.map do |field|
83
84
  field.name.to_sym
84
85
  end
85
86
 
@@ -92,7 +93,7 @@ module Protoable
92
93
  end
93
94
  end
94
95
 
95
- @_protobuf_message
96
+ @protobuf_message
96
97
  end
97
98
  end
98
99
 
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module ActiveRecord
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
- end
5
+ end
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  # Dependencies
22
22
  #
23
23
  gem.add_dependency "activerecord"
24
+ gem.add_dependency "heredity"
24
25
  gem.add_dependency "protobuf", ">= 2.0"
25
26
 
26
27
  ##
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.0.4
4
+ version: 1.0.5
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: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2012-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: heredity
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: protobuf
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +206,6 @@ files:
190
206
  - lib/protoable/convert.rb
191
207
  - lib/protoable/errors.rb
192
208
  - lib/protoable/fields.rb
193
- - lib/protoable/inheritable_class_instance_variables.rb
194
209
  - lib/protoable/persistence.rb
195
210
  - lib/protoable/serialization.rb
196
211
  - lib/protobuf-activerecord.rb
@@ -198,7 +213,6 @@ files:
198
213
  - protobuf-activerecord.gemspec
199
214
  - spec/protoable/convert_spec.rb
200
215
  - spec/protoable/fields_spec.rb
201
- - spec/protoable/inheritable_class_instance_variables_spec.rb
202
216
  - spec/protoable/persistence_spec.rb
203
217
  - spec/protoable/serialization_spec.rb
204
218
  - spec/spec_helper.rb
@@ -222,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
236
  version: '0'
223
237
  segments:
224
238
  - 0
225
- hash: 3415879493130708479
239
+ hash: -2949215824244847758
226
240
  required_rubygems_version: !ruby/object:Gem::Requirement
227
241
  none: false
228
242
  requirements:
@@ -231,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
245
  version: '0'
232
246
  segments:
233
247
  - 0
234
- hash: 3415879493130708479
248
+ hash: -2949215824244847758
235
249
  requirements: []
236
250
  rubyforge_project:
237
251
  rubygems_version: 1.8.24
@@ -241,7 +255,6 @@ summary: Google Protocol Buffers integration for Active Record
241
255
  test_files:
242
256
  - spec/protoable/convert_spec.rb
243
257
  - spec/protoable/fields_spec.rb
244
- - spec/protoable/inheritable_class_instance_variables_spec.rb
245
258
  - spec/protoable/persistence_spec.rb
246
259
  - spec/protoable/serialization_spec.rb
247
260
  - spec/spec_helper.rb
@@ -1,54 +0,0 @@
1
- require 'thread'
2
-
3
- module Protoable
4
- module InheritableClassInstanceVariables
5
- def self.included(klass)
6
- Thread.exclusive do
7
- klass.extend(Protoable::InheritableClassInstanceVariables::ClassMethods)
8
-
9
- klass.class_eval do
10
- @_inheritable_class_instance_variables = [ :_inheritable_class_instance_variables ]
11
- end
12
- end
13
- end
14
-
15
- module ClassMethods
16
- def inheritable_attributes(*args)
17
- Thread.exclusive do
18
- args.flatten.compact.uniq.each do |class_instance_variable|
19
- unless @_inheritable_class_instance_variables.include?(class_instance_variable)
20
- @_inheritable_class_instance_variables << class_instance_variable
21
- end
22
- end
23
-
24
- @_inheritable_class_instance_variables.each do |attr_symbol|
25
- unless self.respond_to?("#{attr_symbol}")
26
- class_eval %Q{
27
- class << self; attr_reader :#{attr_symbol}; end
28
- }
29
- end
30
-
31
- unless self.respond_to?("#{attr_symbol}=")
32
- class_eval %Q{
33
- class << self; attr_writer :#{attr_symbol}; end
34
- }
35
- end
36
- end
37
-
38
- @_inheritable_class_instance_variables
39
- end
40
- end
41
-
42
- def inherited(klass)
43
- super # ActiveRecord needs the inherited hook to setup fields
44
-
45
- Thread.exclusive do
46
- @_inheritable_class_instance_variables.each do |attribute|
47
- attr_sym = :"@#{attribute}"
48
- klass.instance_variable_set(attr_sym, self.instance_variable_get(attr_sym))
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Protoable::InheritableClassInstanceVariables do
4
- pending
5
- end