mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Only load generators when needed
- use hook_for to hook in the serializer and remove load_generators - move generators so they can be found by rails - move to_prepare block to railtie config This commit improves the way the generators are loaded and how they extend the resource generator. * The initializer block has been changed to a `generator` block which is only executed when generators are needed. * The call to `app.load_generators` has been removed. There is no need to load *all* generators. * The `resource_override.rb` has been changed to use `hook_for` to extend the resource generator. * The directory for the generators has been moved to match the way Rails looks to load generators. With `hook_for` it would now be possible for a user to pass `--no-serializer` to skip that option. The `--serialize` option also now shows up in the generator help with `rails g resource --help`. These changes follow the way the Draper gem extends the `controller` generator.
This commit is contained in:
committed by
Benjamin Fleischer
parent
0c2153ac5e
commit
94db22c1e0
@@ -1,4 +1,5 @@
|
||||
require 'test_helper'
|
||||
require 'generators/rails/resource_override'
|
||||
|
||||
class ResourceGeneratorTest < Rails::Generators::TestCase
|
||||
destination File.expand_path('../../../tmp/generators', __FILE__)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require 'test_helper'
|
||||
require 'generators/serializer/serializer_generator'
|
||||
require 'generators/rails/resource_override'
|
||||
require 'generators/rails/serializer_generator'
|
||||
|
||||
class SerializerGeneratorTest < Rails::Generators::TestCase
|
||||
destination File.expand_path('../../../tmp/generators', __FILE__)
|
||||
|
||||
Reference in New Issue
Block a user