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)
Methods
Attributes
| [R] | target |
Public Class methods
Take a default action target. Yield self if block given.
[ show source ]
# File railties/lib/rails_generator/manifest.rb, line 19
19: def initialize(target = nil)
20: @target, @actions = target, []
21: yield self if block_given?
22: end
Public Instance methods
Erase recorded actions.
[ show source ]
# File railties/lib/rails_generator/manifest.rb, line 40
40: def erase
41: @actions = []
42: end
Record an action.
[ show source ]
# File railties/lib/rails_generator/manifest.rb, line 25
25: def method_missing(action, *args, &block)
26: @actions << [action, args, block]
27: end
Replay recorded actions.
[ show source ]
# File railties/lib/rails_generator/manifest.rb, line 30
30: def replay(target = nil)
31: send_actions(target || @target, @actions)
32: end
Rewind recorded actions.
[ show source ]
# File railties/lib/rails_generator/manifest.rb, line 35
35: def rewind(target = nil)
36: send_actions(target || @target, @actions.reverse)
37: end