Module: Protoable::Persistence
- Defined in:
- lib/protobuf/activerecord/protoable/persistence.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#assign_attributes(attributes, options = {}) ⇒ Object
:nodoc:.
-
#update_attributes(attributes, options = {}) ⇒ Object
:nodoc:.
-
#update_attributes!(attributes, options = {}) ⇒ Object
:nodoc:.
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/protobuf/activerecord/protoable/persistence.rb', line 3 def self.included(klass) klass.extend Protoable::Persistence::ClassMethods klass.class_eval do # Override Active Record's initialize method so it can accept a protobuf # message as it's attributes. Need to do it in class_eval block since initialize # is defined in ActiveRecord::Base. # :noapi: def initialize(*args) args[0] = attributes_from_proto(args.first) if args.first.is_a?(::Protobuf::Message) super(*args) end end end |
Instance Method Details
#assign_attributes(attributes, options = {}) ⇒ Object
:nodoc:
36 37 38 39 40 |
# File 'lib/protobuf/activerecord/protoable/persistence.rb', line 36 def assign_attributes(attributes, = {}) attributes = attributes_from_proto(proto) if attributes.is_a?(::Protobuf::Message) super(attributes, ) end |