-
Notifications
You must be signed in to change notification settings - Fork 900
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
Conversation
@abellotti Please review |
|
||
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 |
There was a problem hiding this comment.
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.
6cc42a0
to
425ba46
Compare
@bdunne I'd like to merge this, but could you take care of Mr. Rubocop. Thanks. |
425ba46
to
010572a
Compare
Checked commit bdunne@010572a with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
Thanks @bdunne for the update. Will merge when 🍏 |
Add .class_from_request_data for inverse lookup of model from request_type (cherry picked from commit 440e856)
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) |
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.