Module: Protobuf::ActiveRecord::Persistence

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

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#assign_attributes(attributes) ⇒ Object

:nodoc:



34
35
36
37
38
# File 'lib/protobuf/active_record/persistence.rb', line 34

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

  super(attributes)
end

#initialize(*args, &block) ⇒ Object

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



27
28
29
30
31
# File 'lib/protobuf/active_record/persistence.rb', line 27

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

  super(*args, &block)
end

#update_attributes(attributes) ⇒ Object

:nodoc:



41
42
43
44
45
# File 'lib/protobuf/active_record/persistence.rb', line 41

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

  super(attributes)
end

#update_attributes!(attributes) ⇒ Object

:nodoc:



48
49
50
51
52
# File 'lib/protobuf/active_record/persistence.rb', line 48

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

  super(attributes)
end