def to_attributes( only: nil, except: nil )
      self.class.attributes.each_with_object({}) do |(name, options), attrs|
        next if ( only && !match_attribute?( only, name ) ) || ( except && match_attribute?( except, name ) )
        next unless serialize_attribute?( name, options )

        attrs[name] = send( name )
      end
    end
def to_attributes( only: nil, except: nil )
      self.class.attributes.each_with_object({}) do |(name, options), attrs|
        next if ( only && !match_attribute?( only, name ) ) || ( except && match_attribute?( except, name ) )
        next unless serialize_attribute?( name, options )

        attrs[name] = send( name )
      end
    end
Project the current state of the object to a hash of attributes that can
 be used to restore the attribute object at a later time.

 @param [Array, Regex] only include matching attributes
 @param [Array, Regex] except matching attributes
 @return [Hash] of attributes