lib/rice_bubble/serializer.rb in rice_bubble-0.1.2 vs lib/rice_bubble/serializer.rb in rice_bubble-0.2.0

- old
+ new

@@ -9,11 +9,11 @@ def call(object_to_serialize = nil, path: nil) if object_to_serialize self.class.new(object_to_serialize).call(path:) elsif object self.class.attributes.map do |name, attr| - attr.call(fetch(name), path: path || self.class.name) + attr.call(fetch(name), path: "#{path || self.class.name}.#{name}") end else raise ArgumentError, 'no object to serialize' end end @@ -28,26 +28,9 @@ def valid?(object) self.class.attributes.all? do |name, attr| attr.valid?(attr.fetch(object, name)) end - end - - def validate!(object, path: '', **) - path = self.class.name if path.empty? - - self.class.attributes.each do |name, attr| - value = attr.fetch(object, name) - attr.validate!( - value, - coerced: attr.coerce(value), - path: "#{path}.#{name}" - ) - end - end - - def coerce(object) - object end class << self def call(object = nil, ...) new(object).call(...)