Skip to content

Commit ccc3869

Browse files
committed
Use instance variable for raw_reply in Recaptcha::Reply
1 parent dafa3b7 commit ccc3869

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/recaptcha/reply.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module Recaptcha
22
class Reply
3-
attr_reader :raw_reply, :enterprise
4-
53
def initialize(raw_reply, enterprise: false)
64
@raw_reply = raw_reply
75
@enterprise = enterprise
86
end
97

108
def token_properties
11-
raw_reply['tokenProperties'] if enterprise?
9+
@raw_reply['tokenProperties'] if enterprise?
1210
end
1311

1412
def success?(options = {})
@@ -26,41 +24,41 @@ def success?(options = {})
2624
end
2725

2826
def success
29-
return raw_reply['success'] unless enterprise?
27+
return @raw_reply['success'] unless enterprise?
3028

3129
token_properties&.dig('valid')
3230
end
3331

3432
def hostname
35-
return raw_reply['hostname'] unless enterprise?
33+
return @raw_reply['hostname'] unless enterprise?
3634

3735
token_properties&.dig('hostname')
3836
end
3937

4038
def action
41-
return raw_reply['action'] unless enterprise?
39+
return @raw_reply['action'] unless enterprise?
4240

4341
token_properties&.dig('action')
4442
end
4543

4644
def score
47-
return raw_reply['score'] unless enterprise?
45+
return @raw_reply['score'] unless enterprise?
4846

49-
raw_reply.dig('riskAnalysis', 'score')
47+
@raw_reply.dig('riskAnalysis', 'score')
5048
end
5149

5250
def error_codes
5351
return [] if enterprise?
5452

55-
raw_reply['error-codes'] || []
53+
@raw_reply['error-codes'] || []
5654
end
5755

5856
def error_codes?
5957
!error_codes.empty?
6058
end
6159

6260
def challenge_ts
63-
return raw_reply['challenge_ts'] unless enterprise?
61+
return @raw_reply['challenge_ts'] unless enterprise?
6462

6563
token_properties&.dig('createTime')
6664
end
@@ -104,15 +102,15 @@ def free?
104102
end
105103

106104
def to_h
107-
raw_reply
105+
@raw_reply
108106
end
109107

110108
def to_s
111-
raw_reply.to_s
109+
@raw_reply.to_s
112110
end
113111

114112
def to_json(*args)
115-
raw_reply.to_json(*args)
113+
@raw_reply.to_json(*args)
116114
end
117115
end
118116
end

0 commit comments

Comments
 (0)