Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parent key name as well as parent key id #16

Open
bmclean opened this issue Mar 8, 2018 · 0 comments
Open

Support parent key name as well as parent key id #16

bmclean opened this issue Mar 8, 2018 · 0 comments

Comments

@bmclean
Copy link
Member

bmclean commented Mar 8, 2018

We currently support the parent_key_id attribute as an integer id. We should add support for also using a parent key string name. Something like id_or_name.

Example:

def build_model(entity)
  model_entity = new
  model_entity.id = entity.key.id unless entity.key.id.nil?
  model_entity.id = entity.key.name unless entity.key.name.nil?
  if entity.key.parent.present?
    model_entity.parent_key_id = entity.key.parent.id if entity.key.parent.id.present?
    model_entity.parent_key_id = entity.key.parent.name if entity.key.parent.name.present?
  end
  model_entity
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant