Skip to content

Commit

Permalink
Require needed ActiveSupport core extensions (#283)
Browse files Browse the repository at this point in the history
## Description

When using the CableReady gem (or the `cable_ready-element` gem to be
specific) outside of a Rails context it was complaining about undefined
methods for:

```
NoMethodError: undefined method `seconds' for 0.1:Float
    rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cable_ready-5.0.1/lib/cable_ready/config.rb:31:in `initialize'
```
and
```
NoMethodError: undefined method `many?' for [{:message=>"Test"}]:Array
    rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cable_ready-5.0.1/lib/cable_ready/operation_builder.rb:41:in `block in add_operation_method'
```

Requiring the right ActiveSupport core extensions resolves those errors.

## Why should this be added

This makes the gem more portable and less Rails-dependent.
  • Loading branch information
marcoroth committed Jul 12, 2023
1 parent 1ca5110 commit 2c2ec26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cable_ready/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require "thread/local"

require "active_support/core_ext/enumerable"

module CableReady
# This class is a thread local singleton: CableReady::Channels.instance
# SEE: https://github.com/socketry/thread-local/tree/master/guides/getting-started
Expand Down
2 changes: 2 additions & 0 deletions lib/cable_ready/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require "observer"
require "singleton"

require "active_support/core_ext/numeric/time"

module CableReady
# This class is a process level singleton shared by all threads: CableReady::Config.instance
class Config
Expand Down

0 comments on commit 2c2ec26

Please sign in to comment.