Skip to content

Commit 64c7fee

Browse files
wasifhossainbf4
authored andcommitted
Code cleanup (#2369)
* Lint travis.yml on https://config.travis-ci.com/explore * Replace deprecated 'thread_safe' with 'concurrent-ruby' alternative 'thread_safe' gem is now deprecated and merged into 'concurrent-ruby'. Ref: ruby-concurrency/concurrent-ruby@52e5f37#diff-42d5a45da331eaa07d2b315bd3c9e738 * Fix deprecation warning for Ruby 2.7 https://bugs.ruby-lang.org/issues/15539 * Remove a TODO tag that is already resolved
1 parent 6b093c9 commit 64c7fee

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

.travis.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: ruby
2-
sudo: false
2+
os: linux
33

4-
ruby_supported_versions:
4+
_ruby_supported_versions:
55
- &ruby_2_1 2.1.10
66
- &ruby_2_2 2.2.10
77
- &ruby_2_3 2.3.8
@@ -10,15 +10,15 @@ ruby_supported_versions:
1010
- &ruby_2_6 2.6.5
1111
- &ruby_head ruby-head
1212

13-
jruby_supported_versions:
13+
_jruby_supported_versions:
1414
- &jruby_9_1 jruby-9.1.17.0
1515
- &jruby_9_2 jruby-9.2.8.0
1616
- &jruby_head jruby-head
1717

18-
jdk_supported_versions:
18+
_jdk_supported_versions:
1919
- &jdk_8 openjdk8
2020

21-
rails_supported_versions:
21+
_rails_supported_versions:
2222
- &rails_4_1 RAILS_VERSION=4.1
2323
- &rails_4_1_jruby RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'
2424
- &rails_4_2 RAILS_VERSION=4.2
@@ -41,15 +41,17 @@ cache:
4141
before_install:
4242
- "travis_retry gem update --system 2.7.9"
4343
- "travis_retry gem install bundler -v '1.17.3'"
44-
install: BUNDLER_VERSION=1.17.3 bundle install --path=vendor/bundle --retry=3 --jobs=3
44+
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
4545

4646
script:
4747
- bundle exec rake ci
4848
after_success:
4949
- codeclimate-test-reporter
5050

5151
env:
52-
matrix:
52+
global:
53+
- BUNDLER_VERSION=1.17.3
54+
jobs:
5355
- *rails_4_1
5456
- *rails_4_2
5557
- *rails_5_0
@@ -70,7 +72,7 @@ rvm:
7072
branches:
7173
only: 0-10-stable
7274

73-
matrix:
75+
jobs:
7476
include:
7577
- { rvm: *jruby_9_1, jdk: *jdk_8, env: *rails_4_1_jruby }
7678
- { rvm: *jruby_9_1, jdk: *jdk_8, env: *rails_4_2_jruby }

active_model_serializers.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ Gem::Specification.new do |spec|
5959
spec.add_development_dependency 'timecop', '~> 0.7'
6060
spec.add_development_dependency 'grape', ['>= 0.13', '< 0.19.1']
6161
spec.add_development_dependency 'json_schema'
62-
spec.add_development_dependency 'rake', ['>= 10.0', '< 12.0']
62+
spec.add_development_dependency 'rake', ['>= 10.0', '< 13.0']
6363
end

lib/active_model/serializer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def self.serializer_lookup_chain_for(klass, namespace = nil)
7373
# Used to cache serializer name => serializer class
7474
# when looked up by Serializer.get_serializer_for.
7575
def self.serializers_cache
76-
@serializers_cache ||= ThreadSafe::Cache.new
76+
@serializers_cache ||= Concurrent::Map.new
7777
end
7878

7979
# @api private

lib/active_model/serializer/reflection.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def initialize(*)
8787
# meta ids: ids
8888
# end
8989
# end
90-
def link(name, value = nil)
91-
options[:links][name] = block_given? ? Proc.new : value
90+
def link(name, value = nil, &block)
91+
options[:links][name] = block_given? ? block : value
9292
:nil
9393
end
9494

@@ -102,8 +102,8 @@ def link(name, value = nil)
102102
# href object.blog.id.to_s
103103
# meta(id: object.blog.id)
104104
# end
105-
def meta(value = nil)
106-
options[:meta] = block_given? ? Proc.new : value
105+
def meta(value = nil, &block)
106+
options[:meta] = block_given? ? block : value
107107
:nil
108108
end
109109

test/serializers/serializer_for_with_namespace_test.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ class PublisherSerializer < ActiveModel::Serializer
3535
class BookSerializer < ActiveModel::Serializer
3636
attributes :title, :author_name
3737
end
38+
3839
test 'resource without a namespace' do
3940
book = Book.new(title: 'A Post', author_name: 'hello')
4041

41-
# TODO: this should be able to pull up this serializer without explicitly specifying the serializer
42-
# currently, with no options, it still uses the Api::V3 serializer
43-
result = ActiveModelSerializers::SerializableResource.new(book, serializer: BookSerializer).serializable_hash
42+
result = ActiveModelSerializers::SerializableResource.new(book).serializable_hash
4443

4544
expected = { title: 'A Post', author_name: 'hello' }
4645
assert_equal expected, result

0 commit comments

Comments
 (0)