Sha256: db6f423fe0fbb2778fd79777f8fcce297710f4ef2d4493e4a9dbc2a9e2f3f25d
Contents?: true
Size: 1.56 KB
Versions: 14
Compression:
Stored size: 1.56 KB
Contents
module Protobuf module ActiveRecord module NestedAttributes extend ::ActiveSupport::Concern included do include ::Heredity::InheritableClassInstanceVariables class << self attr_accessor :_protobuf_nested_attributes end @_protobuf_nested_attributes = [] inheritable_attributes :_protobuf_nested_attributes end module ClassMethods # :nodoc: def accepts_nested_attributes_for(*attr_names) attribute_names = attr_names.dup attribute_names.extract_options! attribute_names.map!(&:to_s) super self._protobuf_nested_attributes += attribute_names end end # :nodoc: def assign_nested_attributes_for_collection_association(association_name, attributes_collection) if attributes_collection.first.is_a?(::Protobuf::Message) reflection = self.class._reflect_on_association(association_name) attributes_collection = attributes_collection.map do |attributes| reflection.klass.attributes_from_proto(attributes) end end super(association_name, attributes_collection) end # :nodoc: def assign_nested_attributes_for_one_to_one_association(association_name, attributes) if attributes.is_a?(::Protobuf::Message) reflection = self.class._reflect_on_association(association_name) attributes = reflection.klass.attributes_from_proto(attributes) end super(association_name, attributes) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems