Class: Cloudify::Invalidator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/cloudify/invalidator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInvalidator

Returns a new instance of Invalidator.



7
8
9
# File 'lib/cloudify/invalidator.rb', line 7

def initialize
  @invalidator = Fog::CDN.new(Cloudify.config.credentials) if Cloudify.config.valid? && !Cloudify.config.distribution_id.blank?
end

Instance Attribute Details

#distribution_idObject

Returns the value of attribute distribution_id.



6
7
8
# File 'lib/cloudify/invalidator.rb', line 6

def distribution_id
  @distribution_id
end

Class Method Details

.<<(path) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/cloudify/invalidator.rb', line 14

def @paths.<< path
  raise ArgumentError unless path.kind_of? String
  return self if self.include?(path)
  super
end

Instance Method Details

#<<(path) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
# File 'lib/cloudify/invalidator.rb', line 22

def << path
  raise ArgumentError unless path.kind_of? String
  paths.include?(path) ? paths : paths << path
end

#fogObject



27
28
29
# File 'lib/cloudify/invalidator.rb', line 27

def fog
  @invalidator
end

#invalidate_pathsObject



35
36
37
38
39
# File 'lib/cloudify/invalidator.rb', line 35

def invalidate_paths
  return if !self.valid? || !paths.any?
  STDERR.puts "Invalidating paths: #{paths.join(", ")}"
  send(invalidation_method)
end

#pathsObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/cloudify/invalidator.rb', line 11

def paths
  @paths ||= []

  def @paths.<< path
    raise ArgumentError unless path.kind_of? String
    return self if self.include?(path)
    super
  end
  @paths
end