Module: FastlyRails

Defined in:
lib/fastly-rails/mongoid/surrogate_key.rb,
lib/fastly-rails.rb,
lib/fastly-rails/client.rb,
lib/fastly-rails/engine.rb,
lib/fastly-rails/errors.rb,
lib/fastly-rails/version.rb,
lib/fastly-rails/configuration.rb,
lib/fastly-rails/active_record/surrogate_key.rb,
lib/fastly-rails/rack/remove_set_cookie_header.rb,
lib/fastly-rails/action_controller/cache_control_headers.rb,
lib/fastly-rails/action_controller/surrogate_key_headers.rb

Overview

Adds surrogate key methods to ActiveRecord models Purge methods use a POST over PURGE The choice of this HTTP method should not effect anything

Defined Under Namespace

Modules: ActiveRecord, CacheControlHeaders, Mongoid, Rack, SurrogateKeyHeaders Classes: Client, Configuration, Engine, NoAPIKeyProvidedError, NoServiceIdProvidedError

Constant Summary collapse

VERSION =
"0.7.1"

Class Method Summary collapse

Class Method Details

.clientObject


29
30
31
32
33
34
35
36
37
# File 'lib/fastly-rails.rb', line 29

def self.client
  raise NoAPIKeyProvidedError unless configuration.authenticatable?

  @client ||= Client.new(
    :api_key  => configuration.api_key,
    :user     => configuration.user,
    :password => configuration.password,
  )
end

.configurationObject


8
9
10
# File 'lib/fastly-rails.rb', line 8

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:


12
13
14
# File 'lib/fastly-rails.rb', line 12

def self.configure
  yield configuration if block_given?
end

.purge_by_key(*args) ⇒ Object


25
26
27
# File 'lib/fastly-rails.rb', line 25

def self.purge_by_key(*args)
  client.purge_by_key(*args) if purging_enabled?
end

.purging_enabled?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/fastly-rails.rb', line 21

def self.purging_enabled?
  configuration.purging_enabled?
end

.service_idObject


16
17
18
19
# File 'lib/fastly-rails.rb', line 16

def self.service_id
  raise NoServiceIdProvidedError if configuration.invalid_service_id?
  configuration.service_id
end