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

Extract Expression Substitution code #6654

Merged
merged 2 commits into from
Feb 25, 2016

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Feb 13, 2016

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.

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.
@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 13, 2016

@gtanzillo @dclarizio
Please review

@miq-bot
Copy link
Member

miq-bot commented Feb 13, 2016

Checked commit mkanoor@96845b3 with ruby 2.2.3, rubocop 0.34.2, and haml-lint 0.13.0
2 files checked, 24 offenses detected

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'
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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)?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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.

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 25, 2016

@gtanzillo @Fryguy
Please Review

Fryguy added a commit that referenced this pull request Feb 25, 2016
@Fryguy Fryguy merged commit f0abfb8 into ManageIQ:master Feb 25, 2016
@Fryguy Fryguy modified the milestones: Roadmap, Sprint 37 Ending Mar 7, 2016 Feb 25, 2016
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.

4 participants