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
SUPPORTED_GRAPH_OPTIONS =
[:events].freeze

Constants inherited from Base

Base::LOCK, Base::READONLY_ATTRIBUTES, Base::REQUEST_DEFAULTS

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, #to_json, #tracking_id, validate_setting_exists

Methods included from SubclassTracking

#recursive_subclasses, #subclasses

Constructor Details

#initialize(project, *args) ⇒ Dash

Returns a new instance of Dash.



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

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

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

Class Method Details

.api_resourceObject



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

def self.api_resource
  "dash"
end

Instance Method Details

#as_jsonObject



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

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



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

def diff(actual)
  actual.delete :resource
  actual.delete :created_by
  actual[:template_variables] ||= []
  actual[:graphs].each do |g|
    g[:definition].delete(:status)
  end
  ignore_request_defaults as_json, actual, :graphs, :definition
  super
end

#url(id) ⇒ Object



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

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