Fix a case when CommaJoinedIntegersConverter is given an integer. #8

Merged
merged 1 commit into from Jan 20, 2015

Conversation

Projects
None yet
2 participants
@CvX
Contributor

CvX commented Aug 2, 2013

No description provided.

@CvX CvX merged commit 825323b into master Jan 20, 2015

1 check passed

default The Travis CI build passed
Details

@CvX CvX deleted the comma-joined-integers-fix branch Jan 20, 2015

@pithyless

This comment has been minimized.

Show comment Hide comment
@pithyless

pithyless Jan 20, 2015

Contributor

@CvX what do you think about something like this? I think any code that is type-checking in ruby where it is not explicitly necessary is a bug waiting to happen.

def call(value)
  value = value.to_s
  non_valid = value.gsub(/[0-9,]/, "")
  # ...
end

This also means you won't crash and burn when someone passes in something that's not an Integer or String (and hence does not have #gsub).

Contributor

pithyless commented Jan 20, 2015

@CvX what do you think about something like this? I think any code that is type-checking in ruby where it is not explicitly necessary is a bug waiting to happen.

def call(value)
  value = value.to_s
  non_valid = value.gsub(/[0-9,]/, "")
  # ...
end

This also means you won't crash and burn when someone passes in something that's not an Integer or String (and hence does not have #gsub).

@CvX

This comment has been minimized.

Show comment Hide comment
@CvX

CvX Jan 20, 2015

Contributor

Agree. Changed.

Contributor

CvX commented Jan 20, 2015

Agree. Changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment