| Class | Rails::Generator::Manifest |
| In: |
railties/lib/rails_generator/manifest.rb
|
| Parent: | Object |
Manifest captures the actions a generator performs. Instantiate a manifest with an optional target object, hammer it with actions, then replay or rewind on the object of your choice.
Example:
manifest = Manifest.new { |m|
m.make_directory '/foo'
m.create_file '/foo/bar.txt'
}
manifest.replay(creator)
manifest.rewind(destroyer)
| target | [R] |
Take a default action target. Yield self if block given.
# File railties/lib/rails_generator/manifest.rb, line 19 def initialize(target = nil) @target, @actions = target, [] yield self if block_given? end
Erase recorded actions.
# File railties/lib/rails_generator/manifest.rb, line 40 def erase @actions = [] end
Record an action.
# File railties/lib/rails_generator/manifest.rb, line 25 def method_missing(action, *args, &block) @actions << [action, args, block] end
Replay recorded actions.
# File railties/lib/rails_generator/manifest.rb, line 30 def replay(target = nil) send_actions(target || @target, @actions) end
Rewind recorded actions.
# File railties/lib/rails_generator/manifest.rb, line 35 def rewind(target = nil) send_actions(target || @target, @actions.reverse) end