Module: Protobuf::Mongoid::Persistence

Extended by:
ActiveSupport::Concern
Defined in:
lib/protobuf/mongoid/persistence.rb

Overview

Persistence methods

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#assign_attributes(attributes) ⇒ Object

:nodoc:



37
38
39
40
41
# File 'lib/protobuf/mongoid/persistence.rb', line 37

def assign_attributes(attributes)
  attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)

  super(attributes)
end

#initialize(*args, &block) ⇒ Object

Override Mongoid’s initialize method so it can accept a protobuf message as it’s attributes. :noapi:



31
32
33
34
# File 'lib/protobuf/mongoid/persistence.rb', line 31

def initialize(*args, &block)
  args[0] = attributes_from_proto(args.first) if args.first.is_a?(::Protobuf::Message)
  super(*args, &block)
end

#update(attributes) ⇒ Object

:nodoc:



44
45
46
47
48
# File 'lib/protobuf/mongoid/persistence.rb', line 44

def update(attributes)
  attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)

  super(attributes)
end

#update!(attributes) ⇒ Object

:nodoc:



51
52
53
54
55
# File 'lib/protobuf/mongoid/persistence.rb', line 51

def update!(attributes)
  attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)

  super(attributes)
end