Class: Codily::Elements::Header

Inherits:
ServiceBelonggingBase show all
Defined in:
lib/codily/elements/header.rb

Instance Attribute Summary

Attributes inherited from Base

#fastly_obj, #root

Instance Method Summary collapse

Methods inherited from ServiceBelonggingBase

#initialize, #key, parent_class, #parent_key, #service_id, #service_name

Methods inherited from Base

#as_dsl_hash, def_attr, defaults, #dsl_args, #id, #initialize, #inspect, #key, #name, name_for_attr, #parent, #parent_class, parent_class, #parent_key, #parents, path

Constructor Details

This class inherits a constructor from Codily::Elements::ServiceBelonggingBase

Instance Method Details

#as_hashObject



32
33
34
35
36
37
38
# File 'lib/codily/elements/header.rb', line 32

def as_hash
  super.tap do |x|
    if x.key?(:ignore_if_set)
      x[:ignore_if_set] = !!x[:ignore_if_set] ? 1 : 0
    end
  end
end

#cache_condition(name = nil, &block) ⇒ Object



40
41
42
# File 'lib/codily/elements/header.rb', line 40

def cache_condition(name = nil, &block)
  set_refer_element(:cache_condition, Condition, {name: name, _service_name: self.service_name}, &block)
end

#fastly_classObject



52
53
54
# File 'lib/codily/elements/header.rb', line 52

def fastly_class
  Fastly::Header
end

#request_condition(name = nil, &block) ⇒ Object



44
45
46
# File 'lib/codily/elements/header.rb', line 44

def request_condition(name = nil, &block)
  set_refer_element(:request_condition, Condition, {name: name, _service_name: self.service_name}, &block)
end

#response_condition(name = nil, &block) ⇒ Object



48
49
50
# File 'lib/codily/elements/header.rb', line 48

def response_condition(name = nil, &block)
  set_refer_element(:response_condition, Condition, {name: name, _service_name: self.service_name}, &block)
end

#setupObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/codily/elements/header.rb', line 18

def setup
  delete_if_empty! *%i(
    regex
    substitution
  )
  force_integer! *%i(
    priority
    ignore_if_set
  )
  if @hash.key?(:ignore_if_set)
    @hash[:ignore_if_set] = @hash[:ignore_if_set] == 1
  end
end