Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#coerced? backwards? #17

Open
eval opened this issue Aug 29, 2014 · 0 comments
Open

#coerced? backwards? #17

eval opened this issue Aug 29, 2014 · 0 comments

Comments

@eval
Copy link

eval commented Aug 29, 2014

The implementation of #coerced? is not in line with the documentation (and seems counterintuitive).

The docs state:

# @example when coercion was successful
#     coercer[String].coerced?(1) # => true

The actual behavior is:

coercer = Coercible::Coercer.new
coercer[String].coerced?(1) # => false
coercer[String].coerced?("1") # => true

Maybe I get the idea of a coercer backwards, but the docs seem to describe what I would expect:

string_coercer = Coercible::Coercer.new[String]
string_coercer.coerced?(string_coercer.to_boolean('1')) # => true
# in general:
# x_coercer.coerced?(<value not of type X>) # => true
# x_coercer.coerced?(<value of type X>) # => false

Let me know - I can submit a PR either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant