Method: AngryMob::Target#noticing_changes

Defined in:
lib/angry_mob/target.rb

#noticing_changes(args, &blk) ⇒ Object

Executes actions with full context and all the trimmings.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/angry_mob/target.rb', line 92

def noticing_changes(args,&blk)
  reset!
  @args = args

  ui.push(to_s) do
    do_validation!

    before_state
    before_call if respond_to?(:before_call)

    ui.debug "before_state=#{before_state.inspect}"

    if skip?
      ui.skipped! "skipping"
      return
    end

    # Here's the core of the target:
    if node.dry_run?
      ui.skipped! "DRY RUN: skipping action"
      return
    else
      # riiight here:
      yield
    end

    ui.debug "after_state=#{state.inspect}"

    # If the state's changed, let it be known
    if state_changed?
      changed 
      notify
      ui.ok!
    else
      ui.skipped! "target didn't change"
    end
  
  end
  self
end