Skip to content

Add #to_h to models; make #inspect dump all attributes#1

Merged
shalvah-gs merged 1 commit into
improvementsfrom
better-visibility
Sep 7, 2023
Merged

Add #to_h to models; make #inspect dump all attributes#1
shalvah-gs merged 1 commit into
improvementsfrom
better-visibility

Conversation

@shalvah-gs

@shalvah-gs shalvah-gs commented Sep 7, 2023

Copy link
Copy Markdown

Port of koshilife#64

This PR aims to improve the debugging experience and general UX by making it easier to see what's going on.

First, adding a #to_h method on Calendly models, so you can easily see the raw data as a hash (helpful for generating API payloads, for instance).

Second, increasing the usefulness of the #inspect method by making it print all attributes. Previously, this was what you'd get:

> pp event
=> #<Calendly::Event:27980 uuid="c79022c3-45a1-46e9-96bd-8fab44908b48", name="Testing/Staging ", status="active", ..>

This was super frustrating, as the truncation was hardcoded, and there was no way to see all the attributes at once.

Now you get:

> pp event
=> #<Calendly::Event:27980 uuid="c79022c3-45a1-46e9-96bd-8fab44908b48", name="Testing/Staging ", status="active", created_at=2023-06-29 09:23:34.003966 UTC, end_time=2023-06-30 08:00:00 UTC, event_guests=[], event_memberships=[#<Calendly::User:27900 uuid="0c5d2a34-4113-4cff-9b34-7db34c8dc324", name=nil, slug=nil, email=nil, uri="https://api.calendly.com/users/0c5d2a34-4113-4cff-9b34-7db34c8dc324">], event_type=#<Calendly::EventType:27920 uuid="bc2baf5b-9aae-42b1-8438-6d3079da163c", name=nil, type=nil, slug=nil, active=nil, kind=nil, scheduling_url=nil, uri="https://api.calendly.com/event_types/bc2baf5b-9aae-42b1-8438-6d3079da163c", ..>, invitees_counter=#<Calendly::InviteesCounter:27940 active=1, limit=1, total=1>, location=#<Calendly::Location:27960 type="custom", status=nil, location=nil>, start_time=2023-06-30 07:30:00 UTC, updated_at=2023-06-29 09:23:34.923187 UTC, uri="https://api.calendly.com/scheduled_events/c79022c3-45a1-46e9-96bd-8fab44908b48">

Much longer, but much more helpful, as intended for #inspect.

@shalvah-gs shalvah-gs changed the base branch from master to improvements September 7, 2023 08:45
@shalvah-gs shalvah-gs merged commit 2895278 into improvements Sep 7, 2023
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