Class: Codily::Elements::RequestSetting

Inherits:
ServiceBelonggingBase show all
Defined in:
lib/codily/elements/request_setting.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



50
51
52
53
54
55
56
# File 'lib/codily/elements/request_setting.rb', line 50

def as_hash
  super.tap do |x|
    i(force_ssl force_miss timer_support bypass_busy_wait).each do |k|
      x[k] = !!x[k] ? 1 : 0 if x.key?(k) && !x[k].nil?
    end
  end
end

#fastly_classObject



62
63
64
# File 'lib/codily/elements/request_setting.rb', line 62

def fastly_class
  Fastly::RequestSetting
end

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



58
59
60
# File 'lib/codily/elements/request_setting.rb', line 58

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

#setupObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/codily/elements/request_setting.rb', line 29

def setup
  delete_if_empty! *i(
    default_host
    hash_keys
    request_condition
  )

  force_integer! *i(
    force_ssl
    force_miss
    timer_support
    bypass_busy_wait
    max_stale_age
  )

  # NOTE: They can be 'N/A' (null) on app.fastly.com, but can't be back to N/A after changed to Y or N once?
  i(force_ssl force_miss timer_support bypass_busy_wait).each do |k|
    @hash[k] = @hash[k] == 1 if @hash.key?(k)
  end
end