Class: CFoundry::Service
- Inherits:
-
Object
- Object
- CFoundry::Service
- Defined in:
- lib/cfoundry/service.rb
Overview
Class for representing a user’s service on a given target (via Client).
Goes not guarantee that the service exists; used for both service creation and retrieval, as the attributes are all lazily retrieved. Setting attributes does not perform any requests; use #update! to commit your changes.
Instance Attribute Summary collapse
-
#meta ⇒ Object
Service metadata.
-
#name ⇒ Object
readonly
Service name.
-
#properties ⇒ Object
Service properties.
-
#tier ⇒ Object
Service tier.
-
#type ⇒ Object
Service type (e.g. key-value).
-
#vendor ⇒ Object
Service vendor (redis, mysql, etc.).
-
#version ⇒ Object
Service version.
Instance Method Summary collapse
-
#create! ⇒ Object
Create the service on the target.
-
#created ⇒ Object
Timestamp of when the service was created.
-
#delete! ⇒ Object
Delete the service from the target.
-
#exists? ⇒ Boolean
Check if the service exists on the target.
-
#initialize(name, client, manifest = nil) ⇒ Service
constructor
Create a Service object.
-
#inspect ⇒ Object
:nodoc:.
-
#updated ⇒ Object
Timestamp of when the service was last updated.
Constructor Details
#initialize(name, client, manifest = nil) ⇒ Service
Create a Service object.
You’ll usually call Client#service instead.
33 34 35 36 37 |
# File 'lib/cfoundry/service.rb', line 33 def initialize(name, client, manifest = nil) @name = name @client = client @manifest = manifest end |
Instance Attribute Details
#meta ⇒ Object
Service metadata.
28 29 30 |
# File 'lib/cfoundry/service.rb', line 28 def @meta end |
#name ⇒ Object (readonly)
Service name.
10 11 12 |
# File 'lib/cfoundry/service.rb', line 10 def name @name end |
#properties ⇒ Object
Service properties.
22 23 24 |
# File 'lib/cfoundry/service.rb', line 22 def properties @properties end |
#tier ⇒ Object
Service tier. Usually “free” for now.
25 26 27 |
# File 'lib/cfoundry/service.rb', line 25 def tier @tier end |
#type ⇒ Object
Service type (e.g. key-value).
13 14 15 |
# File 'lib/cfoundry/service.rb', line 13 def type @type end |
#vendor ⇒ Object
Service vendor (redis, mysql, etc.).
16 17 18 |
# File 'lib/cfoundry/service.rb', line 16 def vendor @vendor end |
#version ⇒ Object
Service version.
19 20 21 |
# File 'lib/cfoundry/service.rb', line 19 def version @version end |
Instance Method Details
#create! ⇒ Object
Create the service on the target.
Call this after setting the various attributes.
51 52 53 |
# File 'lib/cfoundry/service.rb', line 51 def create! @client.rest.create_service(@manifest.merge("name" => @name)) end |
#created ⇒ Object
Timestamp of when the service was created.
64 65 66 |
# File 'lib/cfoundry/service.rb', line 64 def created Time.at(["created"]) end |
#delete! ⇒ Object
Delete the service from the target.
44 45 46 |
# File 'lib/cfoundry/service.rb', line 44 def delete! @client.rest.delete_service(@name) end |
#exists? ⇒ Boolean
Check if the service exists on the target.
56 57 58 59 60 61 |
# File 'lib/cfoundry/service.rb', line 56 def exists? @client.rest.service(@name) true rescue CFoundry::NotFound false end |
#inspect ⇒ Object
:nodoc:
39 40 41 |
# File 'lib/cfoundry/service.rb', line 39 def inspect # :nodoc: "#<Service '#@name'>" end |
#updated ⇒ Object
Timestamp of when the service was last updated.
69 70 71 |
# File 'lib/cfoundry/service.rb', line 69 def updated Time.at(["updated"]) end |