Method: Sunshine::App#with_server_apps
- Defined in:
- lib/sunshine/app.rb
#with_server_apps(search_options, options = {}) ⇒ Object
Calls a method for server_apps found with the passed options, and with an optional log message. Supports all App#find options, plus:
- :no_threads
-
bool - disable threaded execution
- :msg
-
“some message” - log message
app.with_server_apps :all, :msg => "doing something" do |server_app|
# do something here
end
app.with_server_apps :role => :db, :user => "bob" do |server_app|
# do something here
end
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'lib/sunshine/app.rb', line 750 def with_server_apps , ={} = .merge if Hash === = [:msg] method = [:no_threads] ? :each : :threaded_each block = lambda do send(method, ) do |server_app| if block_given? yield(server_app) elsif [:send] server_app.send(*[:send]) end end end if Sunshine.logger.info(:app, , &block) else block.call end end |