Skip to content

Commit 72a35ee

Browse files
committed
Ensure ENV keys are seen as strings
Stripe started checking types on the API key at some point, which means our `EnvWrapper` stopped being effective. This patch passes the `is_a?` call through to the underlying ENV value. Fixes payolapayments#256
1 parent 9376e4a commit 72a35ee

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/payola.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ def to_s
139139
def ==(other)
140140
to_s == other.to_s
141141
end
142+
143+
# This is a nasty hack to counteract Stripe checking if the API key is_a String
144+
# See https://github.com/peterkeen/payola/issues/256 for details
145+
def is_a?(other)
146+
ENV[@key].is_a?(other)
147+
end
142148
end
143149

144150
self.reset!
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper'
2+
3+
module Payola
4+
describe EnvWrapper do
5+
describe "delegations" do
6+
it "should delgate is_a?" do
7+
ENV['whatever'] = 'some value'
8+
wrap = EnvWrapper.new('whatever')
9+
expect(wrap.is_a?(String)).to be_truthy
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)