Class: Rocket::Server::App
- Inherits:
-
Object
- Object
- Rocket::Server::App
- Defined in:
- lib/rocket/server/app.rb
Defined Under Namespace
Classes: NotFoundError
Instance Attribute Summary collapse
-
#attributes ⇒ Object
<< self.
Class Method Summary collapse
-
.all ⇒ Object
Returns list of all registered apps.
-
.find(app_id) ⇒ Object
Returns given app if such is registered.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(attrs = {}) ⇒ App
constructor
A new instance of App.
-
#method_missing(meth, *args, &block) ⇒ Object
:nodoc:.
Constructor Details
#initialize(attrs = {}) ⇒ App
Returns a new instance of App.
30 31 32 |
# File 'lib/rocket/server/app.rb', line 30 def initialize(attrs={}) @attributes = attrs end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/rocket/server/app.rb', line 38 def method_missing(meth, *args, &block) # :nodoc: (value = attributes[meth.to_s]) ? value : super(meth, *args, &block) end |
Instance Attribute Details
#attributes ⇒ Object
<< self
28 29 30 |
# File 'lib/rocket/server/app.rb', line 28 def attributes @attributes end |
Class Method Details
.all ⇒ Object
Returns list of all registered apps.
10 11 12 |
# File 'lib/rocket/server/app.rb', line 10 def all Rocket::Server.apps.to_a.map {|id,app| new(app.merge('id' => id)) } end |
.find(app_id) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rocket/server/app.rb', line 19 def find(app_id) if app = Rocket::Server.apps[app_id] new(app.merge('id' => app_id)) else raise NotFoundError, "Application '#{app_id}' does not exist!" end end |
Instance Method Details
#id ⇒ Object
34 35 36 |
# File 'lib/rocket/server/app.rb', line 34 def id attributes['id'] end |