Class: Codily::Elements::ServiceBelonggingBase
- Inherits:
-
Base
- Object
- Base
- Codily::Elements::ServiceBelonggingBase
show all
- Defined in:
- lib/codily/elements/service_belongging_base.rb
Direct Known Subclasses
Backend, CacheSetting, Condition, Dictionary, Domain, Gzip, Header, Healthcheck, RequestSetting, ResponseObject, Settings, Vcl
Instance Attribute Summary
Attributes inherited from Base
#fastly_obj, #root
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#as_dsl_hash, def_attr, defaults, #dsl_args, #id, #inspect, #name, name_for_attr, #parent, #parent_class, #parents, path
Constructor Details
Returns a new instance of ServiceBelonggingBase.
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/codily/elements/service_belongging_base.rb', line 8
def initialize(*)
super
if fastly_obj
service_version = root.service_version_get(fastly_obj.service_id)
raise "[bug?] Root#service_version_set should be called before passing fastly obj to ServiceBelonggingBase.new" unless service_version
@hash[:_service_name] = service_version[:name]
@hash[:_service_id] = service_version[:id]
end
end
|
Class Method Details
.parent_class ⇒ Object
19
20
21
|
# File 'lib/codily/elements/service_belongging_base.rb', line 19
def self.parent_class
Service
end
|
Instance Method Details
#as_hash ⇒ Object
46
47
48
|
# File 'lib/codily/elements/service_belongging_base.rb', line 46
def as_hash
@hash.reject { |k,v| k == :_service_name || k == :_service_id }
end
|
#key ⇒ Object
42
43
44
|
# File 'lib/codily/elements/service_belongging_base.rb', line 42
def key
[service_name, name]
end
|
#parent_key ⇒ Object
23
24
25
|
# File 'lib/codily/elements/service_belongging_base.rb', line 23
def parent_key
service_name
end
|
#service_id ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/codily/elements/service_belongging_base.rb', line 27
def service_id
@hash[:_service_id] ||= begin
service_version = root.service_version_get(service_name)
if service_version
service_version[:id]
else
nil
end
end
end
|
#service_name ⇒ Object
38
39
40
|
# File 'lib/codily/elements/service_belongging_base.rb', line 38
def service_name
@hash[:_service_name]
end
|