Sha256: 94522bcbbdbc2eb42ecdfaf9711cc4a437b86951fd1e3caf67d711b97c3f9643

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

class Fastly
  # Encapsulates behavior of objects requiring both service and version
  class BelongsToServiceAndVersion < Base
    attr_writer :version

    # Return the Service object this belongs to
    def service
      @service ||= fetcher.get(Service, service_id)
    end

    # Get the Version object this belongs to
    def version
      @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)
    end

    # Get the number of the Version this belongs to
    def version_number # rubocop:disable all
      @version
    end # rubocop:enable all

    # :nodoc:
    def as_hash
      super.delete_if { |var| %w(service_id version).include?(var) }
    end

    def self.get_path(service, version, name, _opts = {})
      "/service/#{service}/version/#{version}/#{path}/#{name}"
    end

    def self.post_path(opts)
      "/service/#{opts[:service_id]}/version/#{opts[:version]}/#{path}"
    end

    def self.put_path(obj)
      get_path(obj.service_id, obj.version_number, obj.name)
    end

    def self.delete_path(obj)
      put_path(obj)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fastly-1.2.3 lib/fastly/belongs_to_service_and_version.rb
fastly-1.2.2 lib/fastly/belongs_to_service_and_version.rb
fastly-1.2.1 lib/fastly/belongs_to_service_and_version.rb
fastly-1.2.0 lib/fastly/belongs_to_service_and_version.rb
fastly-1.1.5 lib/fastly/belongs_to_service_and_version.rb