Skip to content

Commit

Permalink
Merge pull request #73 from k0kubun/integer-unification
Browse files Browse the repository at this point in the history
Don't use Fixnum and Bignum in Ruby 2.4
  • Loading branch information
k0kubun committed Jan 19, 2017
2 parents c817733 + fcf21fe commit 8ef010e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lib/garage/representer.rb
Expand Up @@ -166,22 +166,23 @@ def encode_value(value, responder, selector)
end
end

PRIMITIVE_CLASSES = [
ActiveSupport::TimeWithZone,
Date,
Time,
Integer,
Float,
Hash,
Array,
String,
NilClass,
TrueClass,
FalseClass,
Symbol,
]

def primitive?(value)
[
ActiveSupport::TimeWithZone,
Date,
Time,
Bignum,
Fixnum,
Float,
Hash,
Array,
String,
NilClass,
TrueClass,
FalseClass,
Symbol,
].any? {|k| value.is_a?(k) }
PRIMITIVE_CLASSES.any? {|k| value.is_a?(k) }
end

private
Expand Down

0 comments on commit 8ef010e

Please sign in to comment.