Class: FencepostConfigGenerator

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

Instance Method Summary collapse

Instance Method Details

#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",
    file_contents
end

#file_contentsObject



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

def file_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\nFencepost::Fencepost.model_list = YAML.load(\n<<-contents\n\#{Fencepost::Fencepost.generate_model_list.to_yaml}\ncontents\n)\n"
end