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

Add .class_from_request_data for inverse lookup of model from request_type #12007

Merged
merged 1 commit into from
Oct 19, 2016

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Oct 17, 2016

Ease reverse lookup of MiqRequest subclass from the request_type for the API. With the correct subclass the task description and other defaulted attributes will be properly set.

@bdunne
Copy link
Member Author

bdunne commented Oct 17, 2016

@abellotti Please review
@miq-bot add_label provisioning
@miq-bot add_label euwe/yes


delegate :deny, :reason, :stamped_on, :to => :first_approval
delegate :userid, :to => :requester, :prefix => true
delegate :request_task_class, :request_types, :task_description, :to => :class

def self.class_from_request_data(data)
request_type = data[:request_type].to_sym
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:request_type could be missing and this would blow up. Could we have a raise("Missing request_type") before this statement in case it's not specified. The API could rescue from calling this method and return the exception to the caller.

@abellotti
Copy link
Member

abellotti commented Oct 19, 2016

@bdunne I'd like to merge this, but could you take care of Mr. Rubocop. Thanks.

@miq-bot
Copy link
Member

miq-bot commented Oct 19, 2016

Checked commit bdunne@010572a with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 0 offenses detected
Everything looks good. 🍪

@abellotti
Copy link
Member

Thanks @bdunne for the update. Will merge when 🍏

@abellotti abellotti merged commit 440e856 into ManageIQ:master Oct 19, 2016
@bdunne bdunne deleted the class_from_request_data branch October 19, 2016 15:08
@chessbyte chessbyte modified the milestone: Sprint 48 Ending Oct 24, 2016 Oct 20, 2016
chessbyte pushed a commit that referenced this pull request Oct 21, 2016
Add .class_from_request_data for inverse lookup of model from request_type
(cherry picked from commit 440e856)
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log -1
commit 70076998b0b6388f5718a3a4d15b7d78ca3250d8
Author: Alberto Bellotti <abellotti@users.noreply.github.com>
Date:   Wed Oct 19 11:07:49 2016 -0400

    Merge pull request #12007 from bdunne/class_from_request_data

    Add .class_from_request_data for inverse lookup of model from request_type
    (cherry picked from commit 440e856a6f9bcc6be50d7f93d7938492fe6bf267)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants