Class: ForemanPatch::Ticket::Payload

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_patch/ticket/payload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ Payload

Returns a new instance of Payload.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/foreman_patch/ticket/payload.rb', line 7

def initialize(window)
  @window = window

  @safe_render = FieldRender.new(window)

  @raw = {}
  TicketField.all.each do |key|
    @raw.update(key.key => calculate_value(key))
  end

end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'app/services/foreman_patch/ticket/payload.rb', line 5

def raw
  @raw
end

#windowObject (readonly)

Returns the value of attribute window.



5
6
7
# File 'app/services/foreman_patch/ticket/payload.rb', line 5

def window
  @window
end

Instance Method Details

#[](key) ⇒ Object



23
24
25
# File 'app/services/foreman_patch/ticket/payload.rb', line 23

def [](key)
  @raw[key]
end

#keysObject



19
20
21
# File 'app/services/foreman_patch/ticket/payload.rb', line 19

def keys
  TicketField.all.pluck(:key)
end

#to_json(*args) ⇒ Object



27
28
29
# File 'app/services/foreman_patch/ticket/payload.rb', line 27

def to_json(*args)
  @raw.compact.to_json(*args)
end