-
Notifications
You must be signed in to change notification settings - Fork 0
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 methods to update model in form #13
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Updated the form model by adding an `update` method that allows attributes to be altered. Exceptions are raised when this method is used with a collection. Accordingly, tests have been added to the user and product specs to ensure correct functionality and error handling. The 'user' references in the product_spec.rb have also been corrected to 'product'.
Updated the Datory exceptions and form modules to handle cases where a collection attribute is being updated. Introduced a new MisuseError exception for inappropriate method use. Introduced a new 'update_by' method that enables selective update of elements in a collection by specifying their index. Updated the user and product specs to reflect these changes.
The `update_by` method within lib/datory/attributes/form.rb was raising an incorrect error message when invoked without a collection. The error message has been corrected to accurately state that the `update_by` method can't be used "without a collection."
Optimized the variable naming in the form.rb file for better code readability. Changed 'map_index' to 'model_index' to correctly reflect the context and make it more understandable.
This commit extracts common logic for checking if a model is a collection into an individual method named `model_collection?`. The change helps reduce duplication and increases code readability in the `update` and `update_by` methods.
In the methods `update` and `update_by` of 'form.rb', the repetitive task of raising a MisuseError with a specific message has been refactored into a private method called `raise_misuse`. This increases the readability of the code and simplifies the maintenance process.
This update adds a new 'target' method in the 'form' class, and its corresponding tests in the 'user' and 'product' spec files. This method returns the 'context' instance variable for the object, which will enhance the debugging and tracking capabilities.
This commit adds a reader for the model attribute in the Form class of the Datory module. This is followed by updating all calls of @model to the new reader methods inside the Form class. The test cases were also updated to validate the presence of the model attribute.
This commit reorders the model presence checks in user_spec.rb and product_spec.rb test files. The checks for model being present have been moved up so they occur earlier in the test run. This adjustment enhances test readability and troubleshooting.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.