-
Notifications
You must be signed in to change notification settings - Fork 896
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
Extract Expression Substitution code #6654
Conversation
Extracted substitution code from UI specific code so that it can be used in other parts of the application. We would like to use expressions with substitutions as Automate Method.
@gtanzillo @dclarizio |
Checked commit mkanoor@96845b3 with ruby 2.2.3, rubocop 0.34.2, and haml-lint 0.13.0 app/helpers/miq_expression/filter_subst.rb
|
@@ -1,10 +1,13 @@ | |||
# Filter/search/expression methods included in application.rb | |||
require_relative '../../helpers/miq_expression/filter_subst' |
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.
This should not be be necessary if the file is named properly and the class matches. On that note, I am just confused about what the new module class is (since there's no other usage of it), and thus am not sure where it should live. The helpers
are actually "view helpers", so if this is not used in a view, then it doesn't belong here. If it's a controller mixin, then it should live in controllers/mixins, however the OP states that you want to use it in automate.
To me this just feels like it should be a model class that you just instantiate and use or perhaps as a part of MiqExpression the model. Can you elaborate a bit on how this helps you?
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.
@Fryguy
I have a separate WIP PR for Automate Expression Method #6655
where I am going to use these functions.
The 4 methods that I included in the helper file were extracted from the app/controllers/application_controller/filter.rb where it was only available to the UI and the controllers.
I would need these functions to do substitution from the automate expression methods. These instance methods which are in a module can be included by the app/controllers/application_controller/filter.rb as well as the lib/miq_automation_engine/engine/miq_ae_expression_method.rb in my WIP PR.
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.
Are these methods UI specific though, or are they related to any MiqExpression? Can they just be a part of the MiqExpression class (even as class methods)?
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.
@Fryguy
These methods do the substitution into an expression given a set of input parameters. Till now that feature was UI specific, since UI was the only place you could supply user inputs. Maybe @gtanzillo @dclarizio might have more ideas on it.
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.
Based on that it really feels like it belongs in MiqExpression directly.
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.
Looking at this and reading Jason's comments I agree that this code would be better suited as a module that gets mixed in to MiqExpression as class methods. But it could also be taken further by making them instance methods too. Maybe set the substituted expression an a new accessor or something like that.
@gtanzillo @Fryguy |
Extract Expression Substitution code
Extracted substitution code from UI specific code so that
it can be used in other parts of the application. We would like
to use expressions with substitutions as Automate Method.