Class: Fastly::BelongsToServiceAndVersion
- Defined in:
- lib/fastly/belongs_to_service_and_version.rb
Overview
Encapsulates behavior of objects requiring both service and version
Direct Known Subclasses
ACL, Backend, CacheSetting, Condition, Dictionary, Director, Domain, Gzip, Header, Healthcheck, Match, RequestSetting, ResponseObject, S3Logging, Syslog, VCL
Instance Attribute Summary collapse
-
#version ⇒ Object
Get the Version object this belongs to.
Attributes inherited from Base
Class Method Summary collapse
- .delete_path(obj) ⇒ Object
- .get_path(service, version, name, _opts = {}) ⇒ Object
-
.path_escape(path) ⇒ Object
URI escape (including spaces) the path and return it.
- .post_path(opts) ⇒ Object
- .put_path(obj) ⇒ Object
Instance Method Summary collapse
-
#as_hash ⇒ Object
:nodoc:.
-
#service ⇒ Object
Return the Service object this belongs to.
-
#version_number ⇒ Object
Get the number of the Version this belongs to.
Methods inherited from Base
#delete!, #initialize, list_path, path, #require_api_key!, #save!
Constructor Details
This class inherits a constructor from Fastly::Base
Instance Attribute Details
Class Method Details
.delete_path(obj) ⇒ Object
47 48 49 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 47 def self.delete_path(obj) put_path(obj) end |
.get_path(service, version, name, _opts = {}) ⇒ Object
35 36 37 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 35 def self.get_path(service, version, name, _opts = {}) "/service/#{service}/version/#{version}/#{path}/#{path_escape(name)}" end |
.path_escape(path) ⇒ Object
URI escape (including spaces) the path and return it
29 30 31 32 33 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 29 def self.path_escape(path) @uri_parser ||= URI::Parser.new # the leading space in the escape character set is intentional @uri_parser.escape(path, ' !*\'();:@&=+$,/?#[]') end |
.post_path(opts) ⇒ Object
39 40 41 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 39 def self.post_path(opts) "/service/#{opts[:service_id]}/version/#{opts[:version]}/#{path}" end |
.put_path(obj) ⇒ Object
43 44 45 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 43 def self.put_path(obj) get_path(obj.service_id, obj.version_number, obj.name) end |
Instance Method Details
#as_hash ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 24 def as_hash super.delete_if { |var| %w(service_id version).include?(var) } end |
#service ⇒ Object
Return the Service object this belongs to
9 10 11 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 9 def service @service ||= fetcher.get(Service, service_id) end |
#version_number ⇒ Object
Get the number of the Version this belongs to
19 20 21 |
# File 'lib/fastly/belongs_to_service_and_version.rb', line 19 def version_number # rubocop:disable all @version end |