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

Improve work with model and object #22

Merged
merged 33 commits into from
Aug 29, 2024
Merged

Improve work with model and object #22

merged 33 commits into from
Aug 29, 2024

Conversation

afuno
Copy link
Member

@afuno afuno commented Jul 26, 2024

No description provided.

Upgraded several gem versions including activesupport, concurrent-ruby, minitest, servactory, and zeitwerk. This ensures compatibility with the latest features and security patches.
Updated attribute specification in DSL and spec files to include nested classes. Added new methods for converting instances to Hash and for merging attributes in the workspace modules. This improves clarity and ensures consistency in nested attribute definitions and manipulation.
@afuno afuno added the feature label Jul 26, 2024
@afuno afuno added this to the v1.1.0 milestone Jul 26, 2024
@afuno afuno self-assigned this Jul 26, 2024
lib/datory/attributes/workspace.rb Fixed Show fixed Hide fixed
lib/datory/attributes/workspace.rb Fixed Show fixed Hide fixed
lib/datory/context/workspace.rb Fixed Show fixed Hide fixed
lib/datory/context/workspace.rb Fixed Show fixed Hide fixed
This commit updates method names from `to_h` to `to_hash` in the workspace context and service builder files. This change ensures consistency and clarity in method naming conventions across the codebase. These adjustments are necessary to maintain uniformity and avoid potential confusion with Ruby's native `to_h` methods.
Change the `to_hash` method visibility to private within the Workspace module. Update method calls in form.rb and service_builder.rb to use `send` for accessing and modifying model attributes securely.
afuno added 11 commits July 27, 2024 01:42
Changed instance_variable_set to use a symbol argument instead of a string. This ensures more consistent handling of the instance variable setting and avoids potential issues with string interpolation.
Remove commented-out code and streamline the `to_model` method to a concise single line definition. This cleanup enhances code readability and maintains a cleaner codebase.
Use `send` method for better encapsulation in `to_hash` conversions. This change enhances the encapsulation and flexibility for converting nested values to hashes by dynamically calling the `to_hash` method.
Refactor methods to handle Datory::Base objects and Sets, improving serialization robustness. Also, remove redundant to_hash method call in service builder.
Updated model serialization to consistently use the `to_hash` method instead of `parse`. This enhances clarity and ensures uniformity in how objects are converted during serialization.
Refactored to ensure the `to_hash` method is called using its fully qualified name `Datory::Attributes::Serialization::Model.to_hash`. This change improves clarity and avoids potential conflicts with other `to_hash` methods in different contexts.
The `to_hash` method was removed from the Workspace module as it was not being utilized anywhere in the codebase. This simplifies the module by eliminating dead code, thus improving maintainability.
Refactored the `serialize` and `deserialize` methods by removing specific parameters and replacing them with generic keyword arguments. This simplification aims to streamline the methods and improve code maintainability.
Refactored attribute assignment logic from Workspace to a new Model class in the Datory::Attributes module. This change improves code organization and readability by isolating the attribute building process. The Model class ensures cleaner and more maintainable code.
The delete method was previously added but is no longer being utilized in the Workspace class. Removing this method can help simplify the code and reduce potential confusion for future maintenance.
Replaced the `to_model` method with `new` for creating instances in various specs and the callable context. This change removes unnecessary method calls and optimizes object instantiation, facilitating cleaner and more straightforward code. Verified functionality via updated test cases.
Replaced use of each method on attributes with collection_of_attributes to retrieve attribute name and value. This change improves code readability and prepares for future handling of nested attribute hashes.
Updated the `assign_attribute_for` method to use `attr_accessor` instead of `attr_reader`. This allows both reading and writing of model attributes, enhancing flexibility and functionality.
This change updates the deserialize method's parameter to 'data' to better reflect its potential types. The code now handles both String and non-String input uniformly, enhancing readability and maintainability. Additionally, improved accuracy in parameter naming sets a clearer expectation for method behavior.
Renamed variable from `parsed_data` to `prepared_data` for clarity. This change improves code readability by providing a more accurate description of the variable's purpose in the `deserialize` method.
Expanded the serialization logic to convert objects of type Datory::Base to hashes. This ensures that all objects inheriting from Datory::Base are correctly processed during the serialization.
Refactor `deserialize` method to handle Datory::Base objects by converting them to hash. This change improves robustness by including additional checks for the input data type.
Added functionality to differentiate between serialization and deserialization models in the codebase. Updated methods to handle model types appropriately and adjusted test cases to validate both deserialization and serialization scenarios.
Eliminated unnecessary debug `puts` statements and commented code from `new` method and `model.rb` file to improve code readability and maintainability. This cleanup does not affect the functionality of the methods.
lib/datory/context/callable.rb Fixed Show fixed Hide fixed
lib/datory/context/callable.rb Fixed Show fixed Hide fixed
lib/datory/context/callable.rb Fixed Show fixed Hide fixed
afuno added 10 commits August 3, 2024 13:31
Replaced array-based type assignment with dedicated methods for serialization and deserialization. Updated corresponding method calls in the specs to use the new methods for clarity and better code organization.
Replace class variables with instance variables in `callable.rb` to manage model type storage and assignment. This change reduces potential conflicts and ensures thread safety.
Extended the rubocop disable comment in the deserialize method to include Metrics/AbcSize. This ensures that the method passes the code quality checks without modification.
Refactor code to replace "model_type" with "direction" throughout various modules for better readability and consistency. Improve the `to_hash` method in the `Datory::Result` class to exclude ignored keys and handle nested hashes correctly. Update attributes and examples to reflect these changes.
Updated the `servactory` gem to version 2.8.0. Refactored the `Result` class to remove the `to_hash` method implementation, now relying on the base functionality from `Servactory::Result`.
@afuno afuno marked this pull request as ready for review August 29, 2024 14:43
@afuno afuno merged commit 326fe2c into main Aug 29, 2024
23 checks passed
@afuno afuno deleted the features/SRV-157/to_model branch August 29, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant