Module: Zena::Remote::Interface::Update::ConnectionMethods
- Included in:
- ConnectionMethods
- Defined in:
- lib/zena/remote/interface.rb
Overview
Used to mass update
Instance Method Summary collapse
Instance Method Details
#update(query, attributes) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/zena/remote/interface.rb', line 211 def update(query, attributes) if nodes = all(query) # TODO: ask ? logger.info "-\n" logger.info " %-10s: %s" % ['operation', 'mass update'] logger.info " %-10s: %s" % ['timestamp', Time.now] logger.info " %-10s: %s" % ['query', query.inspect] logger.info " %-10s: %s" % ['count', nodes.size] logger.info " change:" attributes.each do |key, value| logger.info " #{key}: #{value.inspect}" end nodes.each do |node| if node.update_attributes(attributes) else "Could not update node #{node.id} (#{node.title}): #{node.errors.inspect}" end end nodes else nil end end |