Merged
Conversation
5b2bb19 to
0d12016
Compare
0d12016 to
006914a
Compare
nicogaldamez
approved these changes
Feb 14, 2025
lib/ruber/object.rb
Outdated
|
|
||
| module Ruber | ||
| class Object | ||
| attr_reader :data |
Member
There was a problem hiding this comment.
Necesitamos este attr_reader?
Contributor
Author
There was a problem hiding this comment.
Originalmente había pensado que podía servir para darle la posibilidad de tener el hash original en el caso de que la persona prefiera eso. Pero no es eso lo que devuelve así que lo voy a volar.
lib/ruber/object.rb
Outdated
Comment on lines
+25
to
+29
| def method(name) | ||
| super unless @data.respond_to?(name) | ||
|
|
||
| @data.public_send(name) | ||
| end |
Contributor
Author
There was a problem hiding this comment.
No, creo que fue un intento que hice para evitar usar el method_missing
lib/ruber/object.rb
Outdated
|
|
||
| result = @data.public_send(name, *args) | ||
|
|
||
| result.is_a?(Data) ? self.class.new(result.to_h) : result |
Member
There was a problem hiding this comment.
Me pregunto si esto no debería estar en to_data_object en lugar de acá y que quede toda la lógica de transformación ahí:
...
if obj.is_a?(Hash)
wrapped = obj.transform_values do |val|
result = to_data_object(val)
result.is_a?(Data) ? self.class.new(result.to_h) : result
end
...def method_missing(name, *args)
super unless @data.respond_to?(name)
@data.public_send(name, *args)
end
Contributor
Author
There was a problem hiding this comment.
buena sugerencia!
This file contains hidden or 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
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.
What
Introduces Ruber::Object class that converts nested Hashes into immutable Data objects
Supports nested hashes, arrays, and primitive values
Provides dot notation access with method_missing
Why
Offers clean, type-safe way to handle structured data
Makes working with nested data structures more intuitive
Provides immutability out of the box