class Eco::API::Common::People::PersonAttributeParser
Class to define a parser/serializer.
def attribute_present(active_when)
by default, an attribute paraser is active if in the entry to parse
def attribute_present(active_when) Proc.new do |source_data| case source_data when Array keys = source_data when Hash keys = source_data.keys else keys = [] end (source_data && keys.include?(self.attr)) || (active_when && active_when.call(source_data)) end end
def def_parser(active_when: nil, &block)
-
active_when(Proc) -- that expects a list of internal attributes or the internal entry itself
Other tags:
- Note: -
Other tags:
- See: Eco::Language::Models::ParserSerializer#def_parser -
def def_parser(active_when: nil, &block) @active_when = attribute_present(active_when) super(&block) end
def parser_active?(source_data)
-
(Boolean)- `true` if there's no callback defined or there is and evaluates `true`
def parser_active?(source_data) @active_when.call(source_data) end