Sha256: ec1f74d6065b37c0b2ec74bf9fcc9705e133cc59531884003455d0763ae7f04f

Contents?: true

Size: 1.47 KB

Versions: 37

Compression:

Stored size: 1.47 KB

Contents

# Settings Object
class Fastly
  # Represent arbitary key value settings for a given Version
  class Settings < Base
    attr_accessor :service_id, :version, :settings
    ##
    # :attr: service_id
    #
    # The id of the service this belongs to.
    #

    ##
    # :attr: version
    #
    # The number of the version this belongs to.
    #

    ##
    # :attr: service
    #
    # Return a hash containing key/value pairs of settings
    #

    # :nodoc:
    def self.get_path(service, number)
      "/service/#{service}/version/#{number}/settings"
    end

    # :nodoc:
    def self.put_path(obj)
      get_path(obj.service_id, obj.version)
    end

    # :nodoc:
    def self.list_path(_opts = {})
      nil
    end

    # :nodoc:
    def self.post_path
      fail "You can't POST to an setting"
    end

    # :nodoc:
    def self.delete_path
      fail "You can't DELETE to an setting"
    end

    # :nodoc:
    def delete!
      fail "You can't delete an invoice"
    end

    # :nodoc:
    def as_hash
      settings
    end
  end

  # Get the Settings object for the specified Version
  def get_settings(service, number)
    hash = client.get(Settings.get_path(service, number))
    return nil if hash.nil?

    hash['settings'] = Hash[['general.default_host', 'general.default_ttl'].collect { |var| [var, hash.delete(var)] }]
    Settings.new(hash, self)
  end

  # Update the Settings object for the specified Version
  def update_settings(opts = {})
    update(Settings, opts)
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fastly-3.0.2 lib/fastly/settings.rb
fastly-3.0.1 lib/fastly/settings.rb
fastly-3.0.0 lib/fastly/settings.rb
fastly-2.5.3 lib/fastly/settings.rb
fastly-2.5.2 lib/fastly/settings.rb
fastly-2.5.1 lib/fastly/settings.rb
fastly-2.5.0 lib/fastly/settings.rb
fastly-2.4.0 lib/fastly/settings.rb
fastly-2.3.1 lib/fastly/settings.rb
fastly-2.3.0 lib/fastly/settings.rb
fastly-2.2.0 lib/fastly/settings.rb
fastly-2.1.0 lib/fastly/settings.rb
fastly-2.0.0 lib/fastly/settings.rb
fastly-1.15.0 lib/fastly/settings.rb
fastly-1.14.0 lib/fastly/settings.rb
fastly-1.13.2 lib/fastly/settings.rb
fastly-1.13.1 lib/fastly/settings.rb
fastly-1.13.0 lib/fastly/settings.rb
fastly-1.12.0 lib/fastly/settings.rb
fastly-1.11.0 lib/fastly/settings.rb