# Ruby Enumerator support for pagination
Source: https://speakeasy.com/blog/ruby_beta_release

Ruby has been an enduring staple of web application development over the last decade, and Speakeasy is thrilled to announce that Speakeasy's Ruby SDK Generation is now available in public beta. This marks a significant milestone in our mission to provide developers with powerful, elegant SDKs across all major programming languages.

Key highlights:

    Idiomatic Ruby design with method chaining and blocks
    Built-in OAuth 2.0 flows with automatic token management
    Enhanced error handling with custom exception hierarchy
    Intelligent pagination for handling large datasets

## Why Ruby matters in 2025

With Ruby powering millions of web applications and the continued innovation in the Ruby ecosystem, Ruby remains a cornerstone of modern web development. The language has evolved from its dynamic roots into a mature platform for building scalable, maintainable applications, with Ruby 3.x introducing features that enhance performance and developer productivity:

### The evolution of Ruby's elegance

#### Ruby 1.8 - Basic dynamic typing

```ruby
def process(data)
  # ...
end
```

#### Ruby 2.0 - Keyword arguments and refinements

```ruby
def process(data:, logger: nil)
  # ...
end
```

#### Ruby 3.x - Pattern matching and improved type annotations

```ruby
def process(data:, logger: nil)
  case data
  in { success: true, result: Array => results }
    results
  in { success: false, error: String => error }
    raise ProcessingError, error
  end
end
```

Modern Ruby offers a balance between developer productivity and enterprise-grade reliability, making it a great choice for today's development teams.

Our beta release brings production-ready Ruby SDK generation to this thriving ecosystem, enabling API providers to deliver exceptional developer experiences to their Ruby users.

## What's new in our beta release

Our Ruby SDK generation includes powerful new capabilities:

### Core features

    Idiomatic Ruby: Leverage Ruby's expressive syntax with proper method chaining and block support
    Typing: First-class support for Sorbet type system, with the flexibility to disable for performance-oriented projects.
    OAuth 2.0: Implement secure authentication flows with built-in token management
    Deep Object Support: Pass complex nested objects in query parameters without serialization headaches
    Minimal Dependencies: We use only what's necessary to keep your dependency tree lean

### Developer experience improvements

    Smart Pagination: Navigate large datasets with Ruby Enumerators that handle pagination automatically
    Resilient Networking: Implement robust retry mechanisms for handling transient API failures
    Extensible SDK Hooks: Customize request/response workflows using Ruby blocks for logging, metrics, and more
    Comprehensive Docs: Access usage examples for every endpoint with copy-pastable code samples

These optimizations ensure that your API integrations remain fast and reliable, even at scale.

## Core SDK Features In-Depth

### Idiomatic Ruby Design

Ruby's philosophy of developer happiness and expressiveness shines through in our SDK design. We've embraced Ruby's conventions to create SDKs that feel natural to Ruby developers.

Here's how our idiomatic approach translates into real code:

```ruby
class Payment
  extend T::Sig
  include Crystalline::MetadataFields

  field :id, ::Integer
  field :amount, ::Float
  field :currency, Models::Components::CurrencyEnum
  field :status, Models::Components::StatusEnum
  field :created_at, ::Date
  field :description, Crystalline::Nilable.new(::String)
  field :owner, ::String

  sig do
    params(
      id: ::Integer,
      amount: ::Float,
      currency: Models::Components::CurrencyEnum,
      status: Models::Components::StatusEnum,
      created_at: ::Date,
      owner: ::String,
      description: T.nilable(::String)
    ).void
  end
  def initialize(id:, amount:, currency:, status:, created_at:, owner:, description: nil)
    @id = id
    @amount = amount
    @currency = currency
    @status = status
    @created_at = created_at
    @description = description
    @owner = owner
  end
end
```

This approach ensures that your code feels natural to Ruby developers, with familiar patterns like question mark methods for boolean checks and expressive method names.

Thanks to our optional support for Sorbet, method signatures can be generated with 100% complete typing.

### Pagination

```ruby

sdk.subsdk.do_multipage.each do |page|
  # SDK handles pagination automatically
  process_page(page)
end
```

### High Accuracy Numbers

For financial and scientific applications, supporting high-accuracy numbers in your SDK is a must. With Speakeasy's Ruby SDK, we support working with arbitrary precision numbers at all times in the SDK. When serializing/deserializing, the maximum precision is dictated by JSON, and Ruby does not currently support encoding arbitrary precision numbers as strings, so some precision may be lost when encoding/decoding objects.

### OAuth 2.0

Implementing OAuth flows correctly can be challenging. Our Ruby SDKs now include partial support for OAuth 2.0, making secure API integration straightforward.

## Get Started Today

Ready to deliver a world-class developer experience to your Ruby users? Here's how to get started:

    [Generate your Ruby SDK in less than 5 minutes](https://www.speakeasy.com/docs/sdks/create-client-sdks)
    [Read the documentation for configuration options](https://www.speakeasy.com/docs/languages/ruby/methodology-ruby)

Ruby has evolved into a powerful, expressive language with a mature ecosystem, and with our SDK generator, you can now provide your users with a developer experience that leverages all these capabilities. Try it out and see how it can simplify your API integration workflow.