Class: Application
- Inherits:
-
EventdServer
- Object
- EventdServer
- Application
- Defined in:
- lib/shot/application.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
Active connected clients.
-
#data ⇒ Object
Temporary data for storage of state-based information.
-
#loaders ⇒ Object
Array of loaders.
-
#routers ⇒ Object
Array of routers.
Instance Method Summary collapse
-
#add_loader(loader) ⇒ Object
Add a loader to the list of custom loaders the application supports.
-
#add_router(router) ⇒ Object
Add a router to the list of custom routers the application supports.
-
#get(key) ⇒ Object
Gets a value from the state-based store.
-
#initialize(options = { :host => '127.0.0.1', :port => 8080 }) ⇒ Application
constructor
Initialize the Application and EventdServer.
-
#set(key, value) ⇒ Object
Sets a value to the state-based store.
Constructor Details
#initialize(options = { :host => '127.0.0.1', :port => 8080 }) ⇒ Application
Initialize the Application and EventdServer. Specifies a default configuration which allows the EventdServer to bind on 127.0.0.1:8080
30 31 32 33 34 35 36 37 |
# File 'lib/shot/application.rb', line 30 def initialize( = { :host => '127.0.0.1', :port => 8080 }) super() @routers = [] @loaders = [] @clients = [] @data = {} setup_handlers end |
Instance Attribute Details
#clients ⇒ Object
Active connected clients
22 23 24 |
# File 'lib/shot/application.rb', line 22 def clients @clients end |
#data ⇒ Object
Temporary data for storage of state-based information
25 26 27 |
# File 'lib/shot/application.rb', line 25 def data @data end |
#loaders ⇒ Object
Array of loaders
19 20 21 |
# File 'lib/shot/application.rb', line 19 def loaders @loaders end |
#routers ⇒ Object
Array of routers
16 17 18 |
# File 'lib/shot/application.rb', line 16 def routers @routers end |
Instance Method Details
#add_loader(loader) ⇒ Object
Add a loader to the list of custom loaders the application supports.
Attributes
-
loader
- A class which inherits from Loader
57 58 59 60 61 62 63 64 65 |
# File 'lib/shot/application.rb', line 57 def add_loader(loader) unless @loaders.include? loader @loaders.push loader @clients.each do |client| client.add_loader loader end end end |
#add_router(router) ⇒ Object
Add a router to the list of custom routers the application supports.
- Note
-
Existing clients will not be handled by the new router.
Attributes
-
router
- A class which inherits from Router
47 48 49 |
# File 'lib/shot/application.rb', line 47 def add_router(router) @routers.push router unless @routers.include? router end |
#get(key) ⇒ Object
Gets a value from the state-based store
69 70 71 |
# File 'lib/shot/application.rb', line 69 def get(key) @data[key] end |
#set(key, value) ⇒ Object
Sets a value to the state-based store
75 76 77 |
# File 'lib/shot/application.rb', line 75 def set(key, value) @data[key] = value end |