Class: Audiothority::Enforcer
- Inherits:
-
Object
- Object
- Audiothority::Enforcer
- Defined in:
- lib/audiothority/enforcer.rb
Instance Method Summary collapse
- #enforce ⇒ Object
-
#initialize(suspects, console, options = {}) ⇒ Enforcer
constructor
A new instance of Enforcer.
Constructor Details
#initialize(suspects, console, options = {}) ⇒ Enforcer
Returns a new instance of Enforcer.
5 6 7 8 9 10 |
# File 'lib/audiothority/enforcer.rb', line 5 def initialize(suspects, console, ={}) @suspects = suspects @console = console @extract = [:extract] || Extract.new @society = [:society] || EmptySociety.new end |
Instance Method Details
#enforce ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/audiothority/enforcer.rb', line 12 def enforce @suspects.each do |path, violations| violations = violations.select(&:applicable?) @extract.(path.children, save: true) do || changes = violations.map do |violation| field = violation.field values = fields_from(, field) choices = choices_from(values) Change.new(field, choices, ) end changes << RewriteChange.new(:track, ) changes << RewriteChange.new(:year, ) @console.say(%(changes for #{path}:)) changes.each do |change| change.present(@console) end if perform_changes? changes.each(&:perform) @society.transfer(path) @console.say end end end end |