# Adding custom code

> Augment your Ruby SDK with custom utilities

This page covers how to add custom logic, methods, and dependencies to your Ruby SDK.

<Info>
  Before getting started, 

  [read about how Fern SDKs use custom code and learn about the `.fernignore` file](/sdks/overview/custom-code)

  .
</Info>

## Adding custom logic

To get started adding custom code:

<Steps>
  <Step title="Create a new file and add your custom logic">
    ```ruby title="lib/<gem_name>/helper.rb"
    module YourGem
      class Helper
        def self.my_helper
          puts "Hello World!"
        end
      end
    end
    ```
  </Step>

  <Step title="Add your file to `.fernignore`">
    ```yaml {3} title=".fernignore"
    # Specify files that shouldn't be modified by Fern

    lib/<gem_name>/helper.rb
    ```
  </Step>

  <Step title="Consume the helper">
    Now your users can consume the helper function by importing it from the SDK.

    ```ruby
    require "your_gem"

    YourGem::Helper.my_helper
    ```
  </Step>
</Steps>

## Adding custom SDK methods

Fern also allows you to add custom methods to the SDK itself (e.g.
`client.my_method()` ) by inheriting the Fern generated client and then
extending it.

<Steps>
  <Step title="Update `generators.yml` configuration">
    Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended.

    ```yaml {4} title="generators.yml"
    - name: fernapi/fern-ruby-sdk
      version: 1.0.0-rc85
      config:
        clientClassName: BaseClient
    ```
  </Step>

  <Step title="Import and extend the generated client">
    First, import the Fern generated base client and extend it. Then, add whatever methods you want.

    ```ruby title="lib/<gem_name>/my_client.rb"
    require_relative "client"

    module YourGem
      class MyClient < BaseClient
        def my_helper
          puts "Hello World!"
        end
      end
    end
    ```
  </Step>

  <Step title="Update `.fernignore`">
    Add the `my_client.rb` to `.fernignore`.

    ```diff title=".fernignore"
    + lib/<gem_name>/my_client.rb
    ```
  </Step>

  <Step title="Consume the method">
    Instead of constructing the generated client, your users will want to construct the extended client.

    ```ruby
    require "your_gem"

    client = YourGem::MyClient.new
    ```

    Now your users can consume the helper function by importing it from the SDK.

    ```ruby
    client.my_helper
    ```
  </Step>
</Steps>

## Adding custom dependencies

<Warning title="Pro and Enterprise feature">
  This feature is available only for the [Pro and Enterprise plans](https://buildwithfern.com/pricing). To get started, reach out to [support@buildwithfern.com](mailto:support@buildwithfern.com).
</Warning>

To add gems that your custom code requires, update your `generators.yml`.

```yaml {4-7} title="generators.yml"
- name: fernapi/fern-ruby-sdk
  version: 1.0.0-rc85
  config:
    extraDependencies:
      faraday: ">= 1.0"
    extraDevDependencies:
      rspec: "~> 3.0"
```