Closed satoren closed 3 months ago
The changes involve the deprecation of the get/2
function across multiple modules, replaced by a new fetch/2
function. A new fetch!/2
function has also been introduced, which raises an error for out-of-bounds access. Documentation and test cases have been updated to reflect these changes, ensuring consistency in the API and enhancing error handling. The modifications span various modules, including Array
, Map
, XmlElement
, and others.
Files | Change Summary |
---|---|
lib/shared_type/array.ex , lib/shared_type/map.ex , lib/shared_type/xml_element.ex , lib/shared_type/xml_fragment.ex |
The get/2 function is deprecated and replaced with fetch/2 , which maintains the same functionality but improves clarity. A new fetch!/2 function is introduced for error handling. Documentation is updated to reflect these changes. |
lib/shared_type/text.ex |
The method for fetching values from a map has been updated from get to fetch , with documentation examples revised accordingly. |
test/shared_type/array_test.exs , test/shared_type/map_test.exs , test/shared_type/xml_element_test.exs , test/shared_type/xml_fragment_test.exs |
Test cases have been updated to replace get with fetch , and new tests for fetch! have been added to ensure proper error handling. Tests now reflect the updated retrieval methods across various modules. |
test/shared_type/xml_text_test.exs |
The test for retrieving an XML fragment has been updated from get to fetch , aligning with the new method for data access. |
sequenceDiagram
participant User
participant Array
participant Map
participant XmlElement
participant XmlFragment
User->>Array: fetch(index)
Array->>Array: Check index
Array->>User: Return {:ok, element} or :error
User->>Map: fetch(key)
Map->>Map: Check key
Map->>User: Return {:ok, value} or :error
User->>XmlElement: fetch(index)
XmlElement->>XmlElement: Check index
XmlElement->>User: Return {:ok, element} or :error
User->>XmlFragment: fetch(index)
XmlFragment->>XmlFragment: Check index
XmlFragment->>User: Return {:ok, element} or :error
🐰 "In the garden where I hop and play,
Thefetch
has come to brighten the day.
Withget
now gone, we leap with cheer,
Fetching our treasures, oh so near!
Errors are caught, no more to fear,
Hopping along with joy, my dear!" 🌼
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
And add
fetch!
Summary by CodeRabbit
New Features
fetch/2
andfetch!/2
functions across various modules, enhancing element retrieval with improved error handling.get/2
function in favor of the new naming conventions.Bug Fixes
Tests
fetch
andfetch!
functions, ensuring comprehensive coverage for both successful and erroneous retrieval scenarios.