Class: CFoundry::V1::ServiceInstance
- Inherits:
-
Object
- Object
- CFoundry::V1::ServiceInstance
- Defined in:
- lib/cfoundry/v1/service_instance.rb
Overview
Class for representing a user’s service on a given target (via Client).
Does 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
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.
-
#eql?(other) ⇒ Boolean
(also: #==)
Basic equality test by name.
-
#exists? ⇒ Boolean
Check if the service exists on the target.
-
#initialize(name, client, manifest = nil) ⇒ ServiceInstance
constructor
Create a Service object.
-
#inspect ⇒ Object
Show string representing the service.
- #invalidate! ⇒ Object
-
#updated ⇒ Object
Timestamp of when the service was last updated.
Constructor Details
#initialize(name, client, manifest = nil) ⇒ ServiceInstance
Create a Service object.
You’ll usually call Client#service instead.
33 34 35 36 37 |
# File 'lib/cfoundry/v1/service_instance.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/v1/service_instance.rb', line 28 def @meta end |
#name ⇒ Object
Service name.
10 11 12 |
# File 'lib/cfoundry/v1/service_instance.rb', line 10 def name @name end |
#properties ⇒ Object
Service properties.
22 23 24 |
# File 'lib/cfoundry/v1/service_instance.rb', line 22 def properties @properties end |
#tier ⇒ Object
Service tier. Usually “free” for now.
25 26 27 |
# File 'lib/cfoundry/v1/service_instance.rb', line 25 def tier @tier end |
#type ⇒ Object
Service type (e.g. key-value).
13 14 15 |
# File 'lib/cfoundry/v1/service_instance.rb', line 13 def type @type end |
#vendor ⇒ Object
Service vendor (redis, mysql, etc.).
16 17 18 |
# File 'lib/cfoundry/v1/service_instance.rb', line 16 def vendor @vendor end |
#version ⇒ Object
Service version.
19 20 21 |
# File 'lib/cfoundry/v1/service_instance.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.
58 59 60 |
# File 'lib/cfoundry/v1/service_instance.rb', line 58 def create! @client.base.create_service(@manifest.merge(:name => @name)) end |
#created ⇒ Object
Timestamp of when the service was created.
71 72 73 |
# File 'lib/cfoundry/v1/service_instance.rb', line 71 def created Time.at([:created]) end |
#delete! ⇒ Object
Delete the service from the target.
51 52 53 |
# File 'lib/cfoundry/v1/service_instance.rb', line 51 def delete! @client.base.delete_service(@name) end |
#eql?(other) ⇒ Boolean Also known as: ==
Basic equality test by name.
45 46 47 |
# File 'lib/cfoundry/v1/service_instance.rb', line 45 def eql?(other) other.is_a?(self.class) && other.name == @name end |
#exists? ⇒ Boolean
Check if the service exists on the target.
63 64 65 66 67 68 |
# File 'lib/cfoundry/v1/service_instance.rb', line 63 def exists? @client.base.service(@name) true rescue CFoundry::NotFound false end |
#inspect ⇒ Object
Show string representing the service.
40 41 42 |
# File 'lib/cfoundry/v1/service_instance.rb', line 40 def inspect "#<ServiceInstance '#@name'>" end |
#invalidate! ⇒ Object
80 81 82 |
# File 'lib/cfoundry/v1/service_instance.rb', line 80 def invalidate! @manifest = nil end |
#updated ⇒ Object
Timestamp of when the service was last updated.
76 77 78 |
# File 'lib/cfoundry/v1/service_instance.rb', line 76 def updated Time.at([:updated]) end |