Class: FencepostConfigGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/fencepost_config_generator.rb

Instance Method Summary collapse

Instance Method Details

#config_contentsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/fencepost_config_generator.rb', line 10

def config_contents
"Rails.application.eager_load!\nFencepost.configure do |config|\n# dev_mode true means that the Fencepost model_list is created every time\n# a Fencepost is created. This allows you to have Fencepost read your models\n# dynamically rather than having to generate a new yaml file every time you\n# want to change your models. Once your models have stabilized, however. You\n# should set this to false and run bundle exec rails g fencepost_config for\n# a performance gain (having the model graph as a class variable rather than\n# creating it from scratch every time)\nconfig.dev_mode = false\nend\n"
end

#create_initializer_fileObject



4
5
6
7
8
# File 'lib/generators/fencepost_config_generator.rb', line 4

def create_initializer_file
  Rails.application.eager_load!
  create_file "config/initializers/fencepost.rb", config_contents
  create_file "config/fencepost.yml", yaml_contents
end

#yaml_contentsObject



26
27
28
29
30
# File 'lib/generators/fencepost_config_generator.rb', line 26

def yaml_contents
"\#{Fencepost::Fencepost.generate_model_list.to_yaml}\n"
end