def to_hash
      self.class.attribute_names.inject({}) do |hash, name|
        val = format_value(send(name.underscore))
        val.empty? ? hash : hash.merge(format_key(name) => val)
      end
    end
def to_hash
      self.class.attribute_names.inject({}) do |hash, name|
        val = format_value(send(name.underscore))
        val.empty? ? hash : hash.merge(format_key(name) => val)
      end
    end
Formats all attributes into a hash of parameters.