Sha256: 230322187033283b6aba808bb9cf19006951bb1fb5db0594904019349e6d1b41
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require 'securerandom' module AxleAttributes module SerializedChild extend ActiveSupport::Concern included do include SuperstoreOverrides alias :eql? :== include AxleAttributes::Versioned include AxleAttributes::HasAttributes self.has_attribute_definition_class = '::AxleAttributes::ChildDefinition' has_attribute :id, type: :string, index: true, editable: false, version: true has_attribute :created_at, type: :time, index: true, editable: false attr_accessor :serialization_instance include AxleAttributes::Provided include AxleAttributes::Validations end module SuperstoreOverrides def initialize(*args) super @attributes['created_at'] ||= Time.current end def attributes=(params) params.each do |attr, value| self.public_send("#{attr}=", value) if respond_to?("#{attr}=") end end def ==(other) super || hash == other.hash end def attributes result = super result.select! { |attr, value| !value.nil? && self.class.attributes[attr] } result end end def hash id.hash end def versioned_attributes attributes.keep_if { |key, value| self.class.attributes[key].versioned? } end def as_search attributes.keep_if { |key, value| self.class.attributes[key].indexed? } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axle_attributes-1.13.2 | lib/axle_attributes/serialized_child.rb |