Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 954aafc

Browse files
committed
Merge pull request #44 from codeclimate/fix-password-type
Fix type inference for Password type
2 parents 2c15caa + ca93171 commit 954aafc

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/axiom/types/password.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
class Axiom::Types::Password < Axiom::Types::String; end
1+
class Axiom::Types::Password < Axiom::Types::String
2+
def self.infer(object)
3+
if object == Axiom::Types::Password
4+
self
5+
end
6+
end
7+
end

test/axiom/types/password_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require File.expand_path('../../../helper', __FILE__)
2+
3+
class Axiom::Types::PasswordTest < CC::Service::TestCase
4+
class TestConfiguration < CC::Service::Config
5+
attribute :password_attribute, Password
6+
attribute :string_attribute, String
7+
end
8+
9+
def test_password_type_inference
10+
assert_equal(
11+
Axiom::Types::Password,
12+
TestConfiguration.attribute_set[:password_attribute].type
13+
)
14+
end
15+
16+
def test_string_type_inference
17+
assert_equal(
18+
Axiom::Types::String,
19+
TestConfiguration.attribute_set[:string_attribute].type
20+
)
21+
end
22+
end

0 commit comments

Comments
 (0)