Module: Archipelago::Disco::Publishable
- Includes:
- Camel
- Included in:
- Archipelago::Dump::Site, Tranny::Manager, Treasure::Chest
- Defined in:
- lib/archipelago/disco.rb
Overview
A module to simplify publishing of services.
If you include it you can use the publish! method at your convenience.
If you want to customize the publishing related behaviour you can call initialize_publishable with a Hash of options.
See Archipelago::Treasure::Chest or Archipelago::Tranny::Manager for examples.
It will store the service_id of this service in a directory beside this file (publishable.rb) named as the class you include into unless you define @persistence_provider before you call initialize_publishable.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.append_features(base) ⇒ Object
Also add the ClassMethods to
base
.
Instance Method Summary collapse
-
#_dump(dummy_param) ⇒ Object
Dump a DRbObject refering to us.
-
#close! ⇒ Object
Closes the persistence backend of this Publishable.
-
#publish!(options = {}) ⇒ Object
Create an Archipelago::Disco::Jockey for this instance using @jockey_options or optionally given :jockey_options.
-
#service_id ⇒ Object
Returns our semi-unique id so that we can be found again.
-
#unpublish! ⇒ Object
Stops the publishing of this Publishable.
-
#valid? ⇒ Boolean
We are always valid if we are able to reply.
Class Method Details
.append_features(base) ⇒ Object
Also add the ClassMethods to base
.
136 137 138 139 |
# File 'lib/archipelago/disco.rb', line 136 def self.append_features(base) super base.extend(ClassMethods) end |
Instance Method Details
#_dump(dummy_param) ⇒ Object
Dump a DRbObject refering to us.
153 154 155 |
# File 'lib/archipelago/disco.rb', line 153 def _dump(dummy_param) DRbObject.new(self)._dump(dummy_param) end |
#close! ⇒ Object
Closes the persistence backend of this Publishable.
203 204 205 206 207 208 |
# File 'lib/archipelago/disco.rb', line 203 def close! unpublish! around_close do @persistence_provider.close! end end |
#publish!(options = {}) ⇒ Object
Create an Archipelago::Disco::Jockey for this instance using @jockey_options or optionally given :jockey_options.
Will publish this service using @service_description or optionally given :service_description.
164 165 166 167 168 169 |
# File 'lib/archipelago/disco.rb', line 164 def publish!( = {}) setup_jockey() around_publish do @jockey.publish(Archipelago::Disco::Record.new(@service_description.merge([:service_description] || {}))) end end |
#service_id ⇒ Object
Returns our semi-unique id so that we can be found again.
213 214 215 |
# File 'lib/archipelago/disco.rb', line 213 def service_id return @service_id ||= @metadata["service_id"] end |
#unpublish! ⇒ Object
Stops the publishing of this Publishable.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/archipelago/disco.rb', line 185 def unpublish! if defined?(@jockey) if valid? around_unpublish do @valid = false if defined?(Archipelago::Disco::MC) && @jockey == Archipelago::Disco::MC @jockey.unpublish(self.service_id) else @jockey.stop! end end end end end |
#valid? ⇒ Boolean
We are always valid if we are able to reply.
174 175 176 177 178 179 180 |
# File 'lib/archipelago/disco.rb', line 174 def valid? if defined?(@valid) @valid else @valid = true end end |