Class: Kongfigure::Resources::Base
- Inherits:
-
Object
- Object
- Kongfigure::Resources::Base
show all
- Defined in:
- lib/kongfigure/resources/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(id, kongfigure_ignore_fields = nil) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/kongfigure/resources/base.rb', line 6
def initialize(id, kongfigure_ignore_fields = nil)
@id = id
@kongfigure_ignore_fields = (kongfigure_ignore_fields || []).map { |field| field.split(".") }
if self.class != Kongfigure::Resources::Plugin && self.class != Kongfigure::Resources::Route
@kongfigure_ignore_fields.push("id")
end
@plugins = []
@updated = false
@unchanged = false
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/kongfigure/resources/base.rb', line 4
def id
@id
end
|
Returns the value of attribute kongfigure_ignore_fields.
4
5
6
|
# File 'lib/kongfigure/resources/base.rb', line 4
def kongfigure_ignore_fields
@kongfigure_ignore_fields
end
|
#plugins ⇒ Object
Returns the value of attribute plugins.
4
5
6
|
# File 'lib/kongfigure/resources/base.rb', line 4
def plugins
@plugins
end
|
#unchanged ⇒ Object
Returns the value of attribute unchanged.
4
5
6
|
# File 'lib/kongfigure/resources/base.rb', line 4
def unchanged
@unchanged
end
|
#updated ⇒ Object
Returns the value of attribute updated.
4
5
6
|
# File 'lib/kongfigure/resources/base.rb', line 4
def updated
@updated
end
|
Class Method Details
.build_all(resources_hash) ⇒ Object
21
22
23
24
25
|
# File 'lib/kongfigure/resources/base.rb', line 21
def self.build_all(resources_hash)
resources_hash.map do |resource_hash|
build(resource_hash)
end
end
|
Instance Method Details
#==(other_object) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/kongfigure/resources/base.rb', line 27
def ==(other_object)
differences = deep_diff(other_object.api_attributes, api_attributes, kongfigure_ignore_fields)
differences_count = differences.flatten.size
if differences_count > 0
ap api_attributes
ap other_object.api_attributes
ap differences
end
differences_count == 0
end
|
#api_name ⇒ Object
54
55
56
|
# File 'lib/kongfigure/resources/base.rb', line 54
def api_name
raise NotImplementedError
end
|
#display_name ⇒ Object
38
39
40
|
# File 'lib/kongfigure/resources/base.rb', line 38
def display_name
identifier
end
|
#has_to_be_deleted? ⇒ Boolean
50
51
52
|
# File 'lib/kongfigure/resources/base.rb', line 50
def has_to_be_deleted?
@updated == false && @unchanged == false
end
|
#mark_as_unchanged ⇒ Object
46
47
48
|
# File 'lib/kongfigure/resources/base.rb', line 46
def mark_as_unchanged
@unchanged = true
end
|
#mark_as_updated ⇒ Object
42
43
44
|
# File 'lib/kongfigure/resources/base.rb', line 42
def mark_as_updated
@updated = true
end
|
#plugin_allowed? ⇒ Boolean
17
18
19
|
# File 'lib/kongfigure/resources/base.rb', line 17
def plugin_allowed?
true
end
|