lib/eco/api/common/people/person_entry.rb in eco-helpers-0.9.4 vs lib/eco/api/common/people/person_entry.rb in eco-helpers-0.9.5
- old
+ new
@@ -52,34 +52,63 @@
# @return [String, nil] the _internal id_ of this person if defined.
def id
@internal_entry["id"]
end
+ def id?
+ @internal_entry.key?("id")
+ end
+
# @return [String, nil] the _external id_ of this person if defined.
def external_id
@internal_entry["external_id"]
end
+ def external_id?
+ @internal_entry.key?("external_id")
+ end
+
# @return [String, nil] the _name_ of this person if defined.
def name
@internal_entry["name"]
end
+ def name?
+ @internal_entry.key?("name")
+ end
+
# @return [String, nil] the _email_ of this person if defined.
def email
@internal_entry["email"]
end
+ def email?
+ @internal_entry.key?("email")
+ end
+
# @return [String, nil] the _supervisor id_ of this person if defined.
def supervisor_id
@internal_entry["supervisor_id"]
end
def supervisor_id=(value)
@internal_entry["supervisor_id"] = value
end
+ def supervisor_id?
+ @internal_entry.key?("supervisor_id")
+ end
+
+ def filter_tags
+ @internal_entry["filter_tags"]
+ end
+
+ def filter_tags?
+ @internal_entry.key?("filter_tags")
+ end
+
+
# Provides a reference of this person.
# @return [String] string summary of this person identity.
def to_s(options)
options = into_a(options)
case
@@ -227,11 +256,12 @@
def _get_from_account (person, attr)
return nil if !person.account
multiple = ["policy_group_ids", "filter_tags"].include?(attr)
value = person.account.send(attr)
- @person_parser.serialize(:multiple, value) if multiple
+ value = @person_parser.serialize(:multiple, value) if multiple
+ value
end
def _get_from_details(person, attr)
return nil if !person.details || !person&.details&.schema_id
unless field = person.details.get_field(attr)
@@ -294,10 +324,10 @@
# Parsing helper that just **parses the values** that have a parser/serializer defined.
# @param aliased_entry [Hash] the entry with the _internal attribute_ names but the _external values_.
# @return [Hash] the `internal entry` with the **internal** attributes names and values.
def _parsed_entry(aliased_entry)
- parsed = @person_parser.defined_attrs.map do |attr|
+ parsed = @person_parser.active_attrs(aliased_entry).map do |attr|
value = @person_parser.parse(attr, aliased_entry)
[attr, value]
end.to_h
aliased_entry.merge(parsed)
end