lib/eco/api/common/loaders/parser.rb in eco-helpers-2.5.8 vs lib/eco/api/common/loaders/parser.rb in eco-helpers-2.5.9

- old
+ new

@@ -99,14 +99,13 @@ keys = source_data.keys else keys = [] end end - end - inheritable_class_vars :attribute + inheritable_class_vars :attribute, :parsing_phase, :serializing_phase def initialize(person_parser) raise "Expected Eco::API::Common::People::PersonParser. Given #{policies.class}" unless person_parser.is_a?(Eco::API::Common::People::PersonParser) person_parser.define_attribute(self.attribute, dependencies: self.class.dependencies) do |attr_parser| _define_parser(attr_parser) @@ -125,13 +124,13 @@ # @param data [Hash, Ecoportal::API::V1::Person] all the person data at the specified `serializing_phase`: # - when `:internal`: it will receive a `Hash` with the **internal values** but the types already serialized to `String`. # - when `:final`: it will receive a `Hash` with the **internal values** and **types**. # - when `:person`: it will receive the `person` object. # @param deps [Hash] the merged dependencies (default to the class object and when calling the parser). - def seralizer(data, deps) - raise "You should implement this method" - end + # def serializer(data, deps) + # raise "You should implement this method" + # end # @return [String, Symbol] the field/attribute or type this parser is linked to. def attribute self.class.attribute end @@ -145,9 +144,10 @@ attr_parser.def_parser(self.class.parsing_phase, &self.method(:parser)) end end def _define_serializer(attr_parser) + return unless respond_to?(:serializer, true) attr_parser.def_serializer(self.class.serializing_phase, &self.method(:serializer)) end end end end