class Moneta::Api::KeyValueSerializer
Public Class Methods
deserialize(attributes)
click to toggle source
# File lib/moneta/api/key_value_serializer.rb, line 16 def deserialize(attributes) attributes.each_with_object({}) do |attribute, hash| hash[attribute[:key].to_sym] = attribute.tap { |a| a.delete(:key) } end end
serialize(entity)
click to toggle source
# File lib/moneta/api/key_value_serializer.rb, line 5 def serialize(entity) attributes = entity.properties attributes.collect do |property, _| value = entity.public_send(property) key = property.to_s.swapcase { 'key' => key, 'value' => value } unless value.nil? end.compact end