Skip to content

refactor for object model support#7

Merged
benjodo merged 4 commits into
mainfrom
refactor
Apr 17, 2025
Merged

refactor for object model support#7
benjodo merged 4 commits into
mainfrom
refactor

Conversation

@benjodo
Copy link
Copy Markdown
Owner

@benjodo benjodo commented Apr 17, 2025

Here's a summary of the changes we've made to implement a Ruby object model for the Pylon API client:

  1. Created Model Structure:
    - Implemented Models::Base class with attribute access through method_missing
    - Added specific model classes for all API resources (User, Issue, Account, etc.)
    - Created a Collection class that implements Enumerable for lists of resources
  2. Updated Client Implementation:
    - Modified all API methods to return model objects instead of raw hashes
    - Added model_class and collection parameters to HTTP request methods
    - Updated handler_response to properly wrap responses in model objects
    - Maintained backward compatibility with the previous hash-based approach
  3. Added Documentation and Examples:
    - Updated the README with examples using the new object model
    - Created a migration guide to help users transition to the object model
    - Added API validation script to verify model compatibility with the actual API
  4. Updated Tests:
    - Modified all tests to work with the new object model
    - Added tests for the model classes themselves
    - All tests are passing with 84.69% line coverage
  5. Updated Version and Changelog:
    - Bumped version to 1.1.0 (as a compatible feature addition)
    - Updated CHANGELOG.md with detailed information about the new object model

The new object model provides a much more intuitive Ruby interface while maintaining backwards
compatibility. Users can now use methods like issue.title instead of hash access issue["title"], and
collections are directly enumerable with methods like each, map, etc.

To validate against the current API documentation, you can use the api_validation.rb script we created,
which will compare our model structures with the actual API responses.

@benjodo benjodo merged commit b195e49 into main Apr 17, 2025
5 checks passed
@benjodo benjodo deleted the refactor branch April 17, 2025 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant