Class: Eye::Application
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_group(group) ⇒ Object
- #alive? ⇒ Boolean
- #debug_data ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, config = {}) ⇒ Application
constructor
A new instance of Application.
- #logger_tag ⇒ Object
- #processes ⇒ Object
-
#resort_groups ⇒ Object
sort processes in name order.
- #send_command(command, *args) ⇒ Object
- #status_data(debug = false) ⇒ Object
- #status_data_short ⇒ Object
- #sub_object?(obj) ⇒ Boolean
Constructor Details
#initialize(name, config = {}) ⇒ Application
Returns a new instance of Application.
5 6 7 8 9 10 |
# File 'lib/eye/application.rb', line 5 def initialize(name, config = {}) @groups = Eye::Utils::AliveArray.new @name = name @config = config debug { 'created' } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/eye/application.rb', line 3 def config @config end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
3 4 5 |
# File 'lib/eye/application.rb', line 3 def groups @groups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/eye/application.rb', line 3 def name @name end |
Instance Method Details
#add_group(group) ⇒ Object
20 21 22 |
# File 'lib/eye/application.rb', line 20 def add_group(group) @groups << group end |
#alive? ⇒ Boolean
50 51 52 |
# File 'lib/eye/application.rb', line 50 def alive? true # emulate celluloid actor method end |
#debug_data ⇒ Object
39 40 |
# File 'lib/eye/application.rb', line 39 def debug_data end |
#full_name ⇒ Object
16 17 18 |
# File 'lib/eye/application.rb', line 16 def full_name @name end |
#logger_tag ⇒ Object
12 13 14 |
# File 'lib/eye/application.rb', line 12 def logger_tag full_name end |
#processes ⇒ Object
60 61 62 63 64 |
# File 'lib/eye/application.rb', line 60 def processes out = [] @groups.each{|gr| out += gr.processes.to_a } Eye::Utils::AliveArray.new(out) end |
#resort_groups ⇒ Object
sort processes in name order
25 26 27 |
# File 'lib/eye/application.rb', line 25 def resort_groups @groups = @groups.sort { |a, b| a.hidden ? 1 : (b.hidden ? -1 : (a.name <=> b.name)) } end |
#send_command(command, *args) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/eye/application.rb', line 42 def send_command(command, *args) info "send_command #{command}" @groups.each do |group| group.send_command(command, *args) end end |
#status_data(debug = false) ⇒ Object
29 30 31 32 33 |
# File 'lib/eye/application.rb', line 29 def status_data(debug = false) h = { name: @name, type: :application, subtree: @groups.map{|gr| gr.status_data(debug) }} h[:debug] = debug_data if debug h end |
#status_data_short ⇒ Object
35 36 37 |
# File 'lib/eye/application.rb', line 35 def status_data_short { name: @name, type: :application, subtree: @groups.map(&:status_data_short) } end |
#sub_object?(obj) ⇒ Boolean
54 55 56 57 58 |
# File 'lib/eye/application.rb', line 54 def sub_object?(obj) res = @groups.include?(obj) res = @groups.any?{|gr| gr.sub_object?(obj)} if !res res end |