Skip to content

Commit c3d76d2

Browse files
Clarify Rails::Generators::Actions#lib doc [ci-skip]
This makes it clear that, when using the block form, the file contents is the return value of the block, rather than the code of the block. (cherry picked from commit e58a9b0)
1 parent f867237 commit c3d76d2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

railties/lib/rails/generators/actions.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,17 @@ def vendor(filename, data = nil)
261261
create_file("vendor/#{filename}", optimize_indentation(data), verbose: false)
262262
end
263263

264-
# Create a new file in the <tt>lib/</tt> directory. Code can be specified
265-
# in a block or a data string can be given.
264+
# Creates a file in +lib/+. The contents can be specified as an argument
265+
# or as the return value of the block.
266266
#
267-
# lib("crypto.rb") do
268-
# "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'"
267+
# lib "foreign.rb", <<~RUBY
268+
# # Foreign code is fun
269+
# RUBY
270+
#
271+
# lib "foreign.rb" do
272+
# "# Foreign code is fun"
269273
# end
270274
#
271-
# lib("foreign.rb", "# Foreign code is fun")
272275
def lib(filename, data = nil)
273276
log :lib, filename
274277
data ||= yield if block_given?

0 commit comments

Comments
 (0)