Class: Kennel::Models::Dash

Inherits:
Base
  • Object
show all
Includes:
OptionalValidations, TemplateVariables
Defined in:
lib/kennel/models/dash.rb

Constant Summary collapse

API_LIST_INCOMPLETE =
true

Constants inherited from Base

Base::LOCK, Base::READONLY_ATTRIBUTES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OptionalValidations

included

Methods included from TemplateVariables

included

Methods inherited from Base

defaults, inherited, #kennel_id, #name, settings, #tracking_id, validate_setting_exists

Methods included from SubclassTracking

#recursive_subclasses, #subclasses

Constructor Details

#initialize(project, *args) ⇒ Dash

Returns a new instance of Dash.



21
22
23
24
# File 'lib/kennel/models/dash.rb', line 21

def initialize(project, *args)
  @project = project
  super(*args)
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



19
20
21
# File 'lib/kennel/models/dash.rb', line 19

def project
  @project
end

Class Method Details

.api_resourceObject



26
27
28
# File 'lib/kennel/models/dash.rb', line 26

def self.api_resource
  "dash"
end

Instance Method Details

#as_jsonObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kennel/models/dash.rb', line 30

def as_json
  return @json if @json
  @json = {
    id: id,
    title: "#{title}#{LOCK}",
    description: description,
    read_only: false,
    template_variables: render_template_variables,
    graphs: render_graphs
  }

  validate_json(@json) if validate

  @json
end

#diff(actual) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/kennel/models/dash.rb', line 46

def diff(actual)
  actual.delete :resource
  actual.delete :created_by
  actual[:template_variables] ||= []
  actual[:graphs].each do |g|
    g[:definition].delete(:status)
    g[:definition][:requests].each { |r| r.delete(:aggregator) }
  end
  super
end

#url(id) ⇒ Object



57
58
59
# File 'lib/kennel/models/dash.rb', line 57

def url(id)
  Utils.path_to_url "/dash/#{id}"
end